Concurrency violation POCKET PC

V

Vladimir O¾ura

I am building a Pocket PC Application that uses a dataGrid. The dataSource
for the dataGrid is a dataView. When I insert a new row into the dataTable
it shows up in the dataView aswelll (that's what I want). The new row is
saved into the database by calling the Update method of the dataAdapter, and
the AcceptChanges method is also called on the table. When I change some
data in the inserted row through the dataGrid the data is not saved
instantlly. It requires the the Button save to be pressed. When the save
button is pressed I get the next error message:

Concurrency violation: the UpdateCommand affected 0 records.

Can someone tell me what that means, and how do I get rid of it.

Thanks,
Vladimir O¾ura
 
J

Jon Skeet [C# MVP]

Vladimir O¾ura said:
I am building a Pocket PC Application that uses a dataGrid. The dataSource
for the dataGrid is a dataView. When I insert a new row into the dataTable
it shows up in the dataView aswelll (that's what I want). The new row is
saved into the database by calling the Update method of the dataAdapter, and
the AcceptChanges method is also called on the table. When I change some
data in the inserted row through the dataGrid the data is not saved
instantlly. It requires the the Button save to be pressed. When the save
button is pressed I get the next error message:

Concurrency violation: the UpdateCommand affected 0 records.

Can someone tell me what that means, and how do I get rid of it.

The problem is that you're trying to update a record which doesn't
exist in the database - because you're calling AcceptChanges on the
table yourself, the DataAdapter thinks you don't need to insert it.
When it later comes to try to update it, it finds it isn't there.
 

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