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
 
Back
Top