|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Insert to DB from DatagridHi 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 Show quote "Robert Bevington" <rbeving***@freenet.de> wrote in message news:eFyh7FuRGHA.3052@TK2MSFTNGP09.phx.gbl... > 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 use ADO.NET 2.0, take look at SqlBulkCopy.WriteToServer. HTH Elton Wang Show quote "Robert Bevington" wrote: > 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 > > > Robert,
In addition to Elton, have a look at this sample on our website. http://www.vb-tips.com/default.aspx?ID=65217d17-ac72-44f3-9d35-421ed535c609 I hope this helps, Cor Show quote "Robert Bevington" <rbeving***@freenet.de> schreef in bericht news:eFyh7FuRGHA.3052@TK2MSFTNGP09.phx.gbl... > 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 > Thanx guys. I was able to solve my problem using SQLBulkCopy.
Rob Show quote "Robert Bevington" <rbeving***@freenet.de> schrieb im Newsbeitrag news:eFyh7FuRGHA.3052@TK2MSFTNGP09.phx.gbl... > 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 > |
|||||||||||||||||||||||