Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pass DataTable/DataSet to SQL Server - Possible?
Message
De
27/06/2005 08:42:40
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
 
À
27/06/2005 00:30:33
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 1.1
OS:
Windows 2000 SP4
Database:
MS SQL Server
Divers
Thread ID:
01026601
Message ID:
01026674
Vues:
19
This message has been marked as the solution to the initial question of the thread.
>VS.NET 2003 - relative ADO.NET newbie
>
>A "checklist" form of an ASP.NET app I'm building pulls 81 rows out of SQL Server and DataBind()s it to a CheckBoxList. The user then checks/unchecks as many of the 81 options as required.
>
>Now I need to save the results. I'm going to DELETE the original 81 rows in SQL Server, INSERT the user's new choices and also copy the same 81 records out to a history table with a datetime stamp.
>
>It would be REALLY nice to be able to pass an ADO.NET DataTable or DataSet back to a SQL Server sproc in some fashion so I can do something like
INSERT INTO CheckListTable
>  SELECT ... FROM < passed (cursor)? > ...
>
>... and then do something similar to the History table as well.
SQL Server BOL says an sproc can only specify a cursor parameter as an Output parameter, not an Input parameter.
>
>As an alternative I could loop through all 81 rows in the DataTable and send them back 1 at a time via standard parameters to an sproc but calling the sproc 81 times seems dumb - somehow feeding SQL Server all the rows in 1 chunk seems a lot more elegant, if possible.

Al,

A DataSet will be easier and more efficient than individual SqlCommands. However, if you want to max out the efficiency of the code, you should consider writing a stored procedure that accepts the foreign key and a concatenated string of the 81 booleans as parameters. Then split the string and perform the updates inside of a single transaction in the stored procedure.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform