R
rmgalante
I have a Windows Forms Application with a DataGridView which is bound
to a typed DataSet. For reasons specific to the application, I add a
record to the database table when a button is clicked on the form. This
button creates a record with default values so the user only has to
change what they do want as defaults.
During the add logic, I programmatically add a row to the typed DataSet
view with the AddMyTableNameRow method. This works. I call the row's
AcceptChanges(). Then I attempt to refresh the DataGridView with the
Refresh() command.
The problem I have is, when I edit one of the rows in the DataGridView
and call the update command, I get the Concurrency violation. The
UpdateCommand affected 0 of the expected 1 rows.
However, if I Fill the adapter after I add a record, then edit a row,
and call the update command, I do not get the Concurrency violation.
This leads me to believe that the grid is not synchronized with the
underlying table after I add a row, and the concurrency violation is
one of those error messages that means "alot of different things could
have caused the problem."
So how do I add a row to the underlying dataset, and make sure the
datagridview is synchronized with the underlying dataset, so that
subsequent updates do not fail?
Thanks.
to a typed DataSet. For reasons specific to the application, I add a
record to the database table when a button is clicked on the form. This
button creates a record with default values so the user only has to
change what they do want as defaults.
During the add logic, I programmatically add a row to the typed DataSet
view with the AddMyTableNameRow method. This works. I call the row's
AcceptChanges(). Then I attempt to refresh the DataGridView with the
Refresh() command.
The problem I have is, when I edit one of the rows in the DataGridView
and call the update command, I get the Concurrency violation. The
UpdateCommand affected 0 of the expected 1 rows.
However, if I Fill the adapter after I add a record, then edit a row,
and call the update command, I do not get the Concurrency violation.
This leads me to believe that the grid is not synchronized with the
underlying table after I add a row, and the concurrency violation is
one of those error messages that means "alot of different things could
have caused the problem."
So how do I add a row to the underlying dataset, and make sure the
datagridview is synchronized with the underlying dataset, so that
subsequent updates do not fail?
Thanks.