Question : Concurrency violation in Access database

Hi All,

I am getting the following error when trying to update an empty table:

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

I am using the following code to save the data:
---
 Me.Validate()
 Me.ExpensesBindingSource.EndEdit()
 Me.ExpensesTableAdapter.Update(MyCustomersDataSet.Expenses)
---

I need to mention, this error only occurs when the table is empty - ie. when trying to add the first record.
If I manually enter one record in the database, everything is fine and I can add new records in my application.

The primary key is set to Autonumber. Could this have anything to do with it?

Thanks in advance.

Answer : Concurrency violation in Access database

try this:

1st DCOUNT the number of Records in the Table,
if >0 then you can APPEND Records with your code.

But if =0 (No Records),
we can create a normal Record (just to insert any dummy Record with),
then UPDATE this Record with your data.

jaffer
Random Solutions  
 
programming4us programming4us