Answer the question
In order to leave comments, you need to log in
How to delete and add rows to the database?
I want to delete and add rows to the database izi datagridview on button click. I made an addition similar to Mssql:
adap.UpdateCommand = cd.GetInsertCommand();
adap.Update(table);
dataGridView1.DataSource = table;
foreach (DataGridViewRow row in dataGridView1.SelectedRows)
{
dataGridView1.Rows.Remove(row);
}
adap.UpdateCommand = cd.GetDeleteCommand();
adap.Update(table);
dataGridView1.DataSource = table;
Dynamic SQL generation for an UpdateCommand is not supported for a SelectCommand that does not return any key column information
Answer the question
In order to leave comments, you need to log in
DataGridView, despite its relatively rich functionality, is only an element for displaying data from a source. That is, you do not need to operate on strings in the dgv itself. Instead, work with the data source it is bound to: the bindingSource or the table itself in your DataSet.
That is, all the actions that you visually perform in the dgv must be performed on the data source.
In addition, I remind you that in order to record changes on the server, you will need to synchronize your DataSet with the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question