Updating a SQL table using a dataadapter
Posted on 2007-07-19
What am I doing wrong?? I am using a dataadapter, filling a dataset, merging it with a dataset which could have new records in it, and then trying to update the original SQL table with the new data from the dataset. My dataset is merged correctly but my SQL table never gets the new data. I think I am missing something with the SQLCommandBuilder step.
Thanks for any help!
Dim cb As SqlCommandBuilder
queryString = "select * from Inventory"
dsadapter1 = New SqlDataAdapter(queryString, conSQL.ConnectionString)
x1 = dsadapter1.Fill(dsfull1, "Inventory")
dsfull1.Merge(newdataset.Tables("NewInventory"), True, MissingSchemaAction.Ignore)
*** Note: dsfull1 has all the new records at this point **
cb = New SqlCommandBuilder(dsadapter1)
x1 = dsadapter1.Update(dsfull1, "Inventory")