concurrency exception

H

Hendri Adriaens

Hi,

I try to run this:

OdbcDataAdapter odbcDA = new OdbcDataAdapter("select * from job_1",
odbcCon);
DataTable dataTable = new DataTable();
odbcDA.Fill(dataTable);
dataTable.Rows[0].BeginEdit();
dataTable.Rows[0]["E1"] = 0.9919919;
dataTable.Rows[0].EndEdit();
odbcDA.Update(dataTable);
dataTable.AcceptChanges();

But it gives:
Concurrency violation: the UpdateCommand affected 0 of the expected 1
records.

I have no other application running that might be working on the table.

What is wrong here?

Thanks, best regards,
-Hendri.
 
H

Hendri Adriaens

I left one line out that I thought didn't do anything (namely creating a
OdbcCommandBuilder obejct). I did do something. Without that line, I
actually get an "invalid update command" exception. With the line, I get the
concurrency violation. See the code below.

I'm really not doing anything difficult. The only thing happening so far is
that I make a connection with the database, with a query copy some records
from a big table to a new table (job_1) and then I want to update this table
as in the code below. That's all.

Does anyone know why it does give this error? What is the solution?

Thank you, best regards,
-Hendri Adriaens.

OdbcDataAdapter odbcDA = new OdbcDataAdapter("select * from job_1",
odbcCon);
DataTable dataTable = new DataTable();
odbcDA.Fill(dataTable);
dataTable.Rows[0].BeginEdit();
dataTable.Rows[0]["E1"] = 0.9919919;
dataTable.Rows[0].EndEdit();
OdbcCommandBuilder odbcBuilder = new OdbcCommandBuilder(odbcDA);
odbcDA.Update(dataTable.GetChanges());
dataTable.AcceptChanges();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top