Datasets and deleting

domon

New Member
I am trying to delete a record from a dataset. Basically I do a DS.Table.Row.Remove() and feed it the row that I want, then call a myDataAdapter.Update(DS). The row IS being successfully removed from the dataset, but when I do the update I get this error: <BR><BR>Could not delete from database. <BR>This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row. <BR><BR>I don't have a clue what it is trying to do!Have you set the deletecommand property of your dataadapter?Yes. The data adapter was created by VS by dragging it from the database. I did check the code though, and it's there and looks...right. Frankly I'm not 100% on how the dataset-data adapter interaction happens. It almost sounds like the data adapter can't propagate the delete through to the datasource because the record is missing in the dataset.http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/bdadotnetdata3.asp. This may help. Make sure the SourceColumn property is set for the parameters of the delete command of the data adapter object. This tells the data adapter which rows it should delete.The problem is I was using Remove instead of Delete. Switched it to Delete and it worked like a charm. Thanks for the pointer to a great example!
 
Back
Top