How to Load data from a Dataset to a Database Table.

Hi,

 I have dumped the data from a textfile into a dataset. But I am not able to load the Data from the Dataset to the SQL Database Table.

 (Since the Rowstate remains 'Unchanged' I wont be able to use SqlDataAdapter.Update. Running through each row to upload to database would prove costly. Hence am trying to findout a simpler way.)

Please let me know if there is anyway at all..

Thanks.
pacchyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ffox04Connect With a Mentor Commented:
I assume you used an adpater to load the text file data into the dataset originally (otherwise the RowState would not be Unchanged).  If so, you want to set your text file adapter.AcceptChangesDuringFill = false; before calling adapter.Fill();  That way you can call Update() on your database adapter and all the newly added rows will go into your database.
0
 
chaniewskimCommented:
Using SqlDataAdapter.Update you also run through each row. So it won't be more costly if you do this.
0
 
TheAvengerCommented:
In the worst case, you can go over all rows and change a value (maybe to it's previous value) so that the record is marked changed. Then call Update. However the idea of ffox seams to be better
0
All Courses

From novice to tech pro — start learning today.