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

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?
 
C

Cor Ligthert

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"
 
P

Prodip Saha

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top