Problem updating database after deleting someting!

I am working on basic sql using C # with bindings and adapters. I have successfully added the data to my database and can then update with no problem. But when I try to delete some data and then UPDATE it throws an exception:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll Additional information: The update requires a valid DeleteCommand when passing a DataRow collection with rows deleted.

The code:

private void button4_Click(object sender, EventArgs e)
{
    table1TableAdapter.Update(dataSet1);
}

private void button5_Click(object sender, EventArgs e)
{
    table1BindingSource.RemoveCurrent();
}

      

Why can't I update my database after deleting something from it?

0


a source to share


1 answer


You remove the code without removing anything from the db. This is removing the binding to the data source. So when you call Update()

on this datasource, it is no longer tied to anything.



0


a source







All Articles