Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

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.
0
pacchy
Asked:
pacchy
1 Solution
 
chaniewskimCommented:
Using SqlDataAdapter.Update you also run through each row. So it won't be more costly if you do this.
0
 
ffox04Commented:
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now