bioS
10-06-2003, 07:14 AM
Hi,
I have a problem when I try to update an Access database.
In a Web Form, I've build a OleDbConnection, a OleDbDataAdapter and a DataSet.
I can read data from the database with them, but when I try to make some changes to the DataSet, I can't send them to the DB. I get an error saying:
Concurrency violation: the UpdateCommand affected 0 records
It's a really simple page, so no other pages modify the DB meanwhile.
Here's the C# code:
...
picDataAdapter.Fill(galleryDS, "pictures");
...
DataTable picTable = galleryDS.Tables["pictures"];
DataView picView = new DataView(picTable, "id_pic=2 and isVisible=true","", DataViewRowState.CurrentRows);
picView.BeginInit();
picView[0]["myInt"] = (int)picView[0]["myInt"]+1;
picView.EndInit();
picDataAdapter.Update(galleryDS, "pictures");
In the 'pictures' table there are string, integer, date and boolean data.
I've found many people asking this question in forums, but I couldn't find any answer...
The only thing I could find was that this Exception can occur if some data in the row have been modified meanwhile in the DB source before trying to send the update. But as I said, it's not supposed to the case here.
Any idea...?
I have a problem when I try to update an Access database.
In a Web Form, I've build a OleDbConnection, a OleDbDataAdapter and a DataSet.
I can read data from the database with them, but when I try to make some changes to the DataSet, I can't send them to the DB. I get an error saying:
Concurrency violation: the UpdateCommand affected 0 records
It's a really simple page, so no other pages modify the DB meanwhile.
Here's the C# code:
...
picDataAdapter.Fill(galleryDS, "pictures");
...
DataTable picTable = galleryDS.Tables["pictures"];
DataView picView = new DataView(picTable, "id_pic=2 and isVisible=true","", DataViewRowState.CurrentRows);
picView.BeginInit();
picView[0]["myInt"] = (int)picView[0]["myInt"]+1;
picView.EndInit();
picDataAdapter.Update(galleryDS, "pictures");
In the 'pictures' table there are string, integer, date and boolean data.
I've found many people asking this question in forums, but I couldn't find any answer...
The only thing I could find was that this Exception can occur if some data in the row have been modified meanwhile in the DB source before trying to send the update. But as I said, it's not supposed to the case here.
Any idea...?