Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting Pkey back from sql server
Message
De
06/12/2004 14:43:20
 
 
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
VB.NET 1.1
OS:
Windows XP SP1
Database:
MS SQL Server
Divers
Thread ID:
00966751
Message ID:
00967291
Vues:
5
Bernard,

>>I'm assuming your SP's take parameters from the client and insert them into the correct field returning the pkey field to the client?<

My Data Access classes automatically generate the parameters for the SP's, based on the the columns in the DataTable that is being updated. Typically, the DataTable's columns will be the same columns that are in the database's table (and the Stored Proc, of course, only has parameters for the columns in that database table). If the DataTable has additional columns, then you have two options prior to calling the ExecuteNonQuery(): one, to just remove the parameter that was auto-generated, or two, use the CommandBuilder's .DeriveParameters() method (so, yeah, you *can* still use the CommandBuilder if you prefer). I try to avoid that, as the .DeriveParameters() method makes another trip to SQL Server to determine what your parameters should be, but it's not *too* bad since this is all server-side, so there isn't *that* much of a hit, speed-wise.

And yes, the PK column is an InputOutput column, so the SP can return a PK in an Insert situation.

>>I never thought of using foxpro to generate the skeleton commands!<

hehehe ... the main reason we did it that way was because this whole process was started more than 2-1/2 years ago, while still in the process of learning .NET. Since VFP is so great at string handling, and since at the time I knew VFP way better than I knew .NET, it was a no-brainer to use it for this. Our whole SQL Server database create/maintenance utility is entirely written in VFP still.

~~Bonnie




>Hi Bonnie,
>
>Again thanks for the reply, it's really appreciated...
>
>I think I'm going to continue down the road of using the command builder for a little longer. I guess I'll have to use the MS recommended approach of running an SP from the insertcommand.
>
>If this doesn't pan out then I might have to have a look at having a dedicated SP for the select / update and delete operations.
>
>I'm assuming your SP's take parameters from the client and insert them into the correct field returning the pkey field to the client?
>
>I never thought of using foxpro to generate the skeleton commands!
>
>Many thanks , Bernard
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform