Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pass DataTable/DataSet to SQL Server - Possible?
Message
From
27/06/2005 08:42:40
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
27/06/2005 00:30:33
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 1.1
OS:
Windows 2000 SP4
Database:
MS SQL Server
Miscellaneous
Thread ID:
01026601
Message ID:
01026674
Views:
18
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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform