Strange concurrency error

J

John

Hi

I have a perfectly working vs 2003 winform data app. All the data access
code has been generated using the data adapter wizard and then pasted into
the app.

I had to add a new field in the backend access db which I did. I then
dragged the table to the dataset and deleted the old table from the dataset
it so the dataset can see the new field as well.

The problem is that when in update command code I add these two lines

Me.updcomCompanies.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Web_Enabled",
System.Data.OleDb.OleDbType.Boolean, 2, "Web_Enabled"))

and

Me.updcomCompanies.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Web_Enabled",
System.Data.OleDb.OleDbType.Boolean, 2,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"Web_Enabled", System.Data.DataRowVersion.Original, Nothing))

I startgetting a data concurrency error on mydataadapter.update() method. I
know that there is no data concurrency problem as I am the only user testing
the app. Obviously the error is misleading. What can I do from here to fix
this problem?

Thanks

Regards
 
B

Bart Mermuys

Hi,

John said:
Hi

I have a perfectly working vs 2003 winform data app. All the data access
code has been generated using the data adapter wizard and then pasted into
the app.

I had to add a new field in the backend access db which I did. I then
dragged the table to the dataset and deleted the old table from the
dataset it so the dataset can see the new field as well.

The problem is that when in update command code I add these two lines

Me.updcomCompanies.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Web_Enabled",
System.Data.OleDb.OleDbType.Boolean, 2, "Web_Enabled"))

and

Me.updcomCompanies.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Web_Enabled",
System.Data.OleDb.OleDbType.Boolean, 2,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte), "Web_Enabled", System.Data.DataRowVersion.Original, Nothing))

You say added these lines, not sure if they came from the wizard too, but
why didn't you configurated the DataAdapter again and copy-pasted it _all_,
just to be sure ?

False concurrency violations aren't always easy to fix definately not
without seeing full code and maybe the db unless it's simple. There are
many reasons that can cause it:
- calling AcceptChanges at the wrong time
- not filling all the columns
- not retrieving auto-generated keys (this can be easily spot, because it
occurs after insert-update-change-update)
- other key problems
....

You could add an eventhandler to DataAdapter.RowUpdating, check for
e.StatementType is Update and then check e.Command, print out the sql text
and all parameter(+values), the old values must be the same as they are in
the DB and check if the key is correct.

You haven't really said when they occur, simple change-update or delete too,
sometimes or always,etc... ?

HTH,
Greetings
 

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