Ginanity Posted November 19, 2007 Posted November 19, 2007 I'm using a datagridview in my application that get's data from a MySql Server (not localhost) via the ODBC 3.51 driver. Now i'm trying to update the mysql server with the changed data in the datagridview using a dataset OpenConnection(); initInfo(); string _sql = "SELECT * FROM " +tabel; da = new OdbcDataAdapter(_sql, con); OdbcCommandBuilder _cb = new OdbcCommandBuilder(da); if (ds.HasChanges() == true) { da.Update(ds); ds.AcceptChanges(); } CloseConnection(); I get following error: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records. The problem is that I have no idea what table or rows are in the datagridview because the user can add a mysql database and the application generates a listview with the tables. On click the selected table appears in the datagridview. So i can't use the update statement or use a datatable... Quote
Nate Bross Posted December 31, 2007 Posted December 31, 2007 where is "ds" coming from? Do you maybe need an Adapter.Fill(ds); before the ds.HasChanged Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
techmanbd Posted January 1, 2008 Posted January 1, 2008 I would say swap the update command and accept changes. You need to accept the changes before you update the table. Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.