Insert to DB from Datagrid

  • Thread starter Thread starter Robert Bevington
  • Start date Start date
R

Robert Bevington

Hi everyone,

I have succesfully populated a datagrid with data from an XML file. Now I
want to insert the data into a SQL database table. The database table might
be new and empty, or it might already contain data. What's the best
approach? INSERT To?

Thanx for any pointers in the right direction.

Rob
 
Hi Robert:

If you have the Diffgram with the XML file (so there's rowstate) then you
can just configure an Adapter with each command you need and point it to the
DB calling update. If you don't have rowstate, you're going to need to loop
through the rows, figure out what actions you want to take, load your params
from the datarow values and then fire an ExecuteNonQuery. If you have the
risk of key voilations then make sure to check If Exists beforehand so you
don't throw unnecessary exceptions.

If I understand the problem correctly, this should do it for you.

Cheers,

Bill
 

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

Back
Top