Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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...

  • 1 month later...
Posted

where is "ds" coming from?

 

Do you maybe need an

Adapter.Fill(ds); 

before the

ds.HasChanged

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted

I would say swap the update command and accept changes.

 

You need to accept the changes before you update the table.

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...