Sunday, February 19, 2012

How to build an SQL-string from a record

Hi,
I need a solution for this in SQL Server, or in VB.NET, so for this reason I
posted it to the 2 newsgroups.
I need to build an SQL String from a given record.
For exemple: I have in my table tblMyCows this record:
CowID: 1
CowName: Bella (a typical Belgian cowname)
CowGender: Female
I should have something that generates me the Insert-statement for it: like
this: "INSERT INTO tblMyCows (CowID, CowName, CowGender) VALUES (1, 'Bella',
'Female')".
If possible the same with an update an delete statement, and it would be
really nice if it could detect itself the primary keys, and use them for for
the update and Delete statements.
Anybody any idea?
Thanks a lot in advance,
PieterPieter,
Do you now need Bella because you was yesterday to much involved with
Stella.
I count 4 newsgroups, not 2.
However your problem sounds not difficult for me, what I not direct see, is
if the tblMycows is a datatable or that it is a table in a database?
Cor|||Hi Pieter,
maybe this can be of help (haven't tested it yet)
http://vyaskn.tripod.com/code.htm#inserts
btw I would rather be involved with Stella than with Heineken ;-)
hth Peter
"Cor Ligthert" <notmyfirstname@.planet.nl> schreef in bericht
news:O4vtTtZSFHA.3052@.TK2MSFTNGP09.phx.gbl...
> Pieter,
> Do you now need Bella because you was yesterday to much involved with
> Stella.
> I count 4 newsgroups, not 2.
> However your problem sounds not difficult for me, what I not direct see,
is
> if the tblMycows is a datatable or that it is a table in a database?
> Cor
>|||Hehe it was Jupiler :-)
And tblMyCows is a table in a Database.
"Cor Ligthert" <notmyfirstname@.planet.nl> wrote in message
news:O4vtTtZSFHA.3052@.TK2MSFTNGP09.phx.gbl...
> Pieter,
> Do you now need Bella because you was yesterday to much involved with
> Stella.
> I count 4 newsgroups, not 2.
> However your problem sounds not difficult for me, what I not direct see,
is
> if the tblMycows is a datatable or that it is a table in a database?
> Cor
>|||Hm thanks, it seems really nice, and just the thing I was looking for :-)
"Peter Proost" <pproost@.nospam.hotmail.com> wrote in message
news:OnQUGwZSFHA.2788@.TK2MSFTNGP09.phx.gbl...
> Hi Pieter,
> maybe this can be of help (haven't tested it yet)
> http://vyaskn.tripod.com/code.htm#inserts
> btw I would rather be involved with Stella than with Heineken ;-)
> hth Peter
>
>
> "Cor Ligthert" <notmyfirstname@.planet.nl> schreef in bericht
> news:O4vtTtZSFHA.3052@.TK2MSFTNGP09.phx.gbl...
> > Pieter,
> >
> > Do you now need Bella because you was yesterday to much involved with
> > Stella.
> > I count 4 newsgroups, not 2.
> >
> > However your problem sounds not difficult for me, what I not direct see,
> is
> > if the tblMycows is a datatable or that it is a table in a database?
> >
> > Cor
> >
> >
>|||Pieter,
> Hehe it was Jupiler :-)
You don't believe it, that was what I wrote first.
However Bella and Stella did sound better.
:-)
I have no sample at hand I will try to make it (I don't promish I succeed),
than probably I show it tomorrow. (I have the other way around).
Cor|||Pieter,
Wrong answer (not the jupiler), I have that part from the sample from which
in my opinion you should be able to do the rest yourself, when not, than
reply.
Have a look in this message.
http://groups-beta.google.com/group/microsoft.public.dotnet.languages.vb/msg/470d93378c5467f8?hl=en
Cor

No comments:

Post a Comment