Can we insert all data in the DataSet once a time into Sql Server

  • Thread starter Thread starter ad
  • Start date Start date
A

ad

I want to append data into Sql Server from xml file in tree step

1. A user uploads an xml file in a Web Form

2. A Dataset object read the xml file with the ReadXml method.

3. The Dataset append its record into SqlServer one by one in a loop.

But can we insert all data in the DataSet once a time into Sql Server?
 
Ad,

When it is really an insert and there are no concurrencyproblems than you
can just do an SQLDataadapter with an SQL insert instruction.

Cor

"ad"
 
I don't think you can append all records in SQL at once from a dataset(or
datatable). It does the loop for you.

How about this approach?
Create a stored procedure in SQL Server that takes xml string as an input
parameter along with other params. You can insert all records into a temp
table in SQL and insert them all at once in the intended table. You can also
use transaction in the procedure (if needed for data integrity). xml is a
good feature in SQL.

Use the xml string you just read from the file or recreate the xml string
from the dataset and pass it to the stored procedure.

Hope this help.
Prodip
 
Back
Top