Concurrency Violations in SqlCeDataAdapter

R

Raja

Hi all,

I am having a problem with using SqlCeDataAdapter to update the
database. I am working with the dataset and the data adapter to do my
Select,Insert,Update,Delete . The Dataset holds the results of the
select commmand and I store the adapter in a Hashtable .When the user
does an insert ,I retrieve this adapter from the Hashtable , set the
Insert command and update the adapter.This works fine and I am able to
insert multiple rows . The problem appears when I try to update a newly
inserted row , one that was not displayed in the search results when
the application loaded this form. Then I get a Concurrency violation ,
No records updated exception . The same goes for deleted rows . Can
some one tell me what is happening ?.Also how do I go about solving
this problem?.

Thanks,
Raja
 
I

Ilya Tumanov [MS]

Not sure I understand your scenario. Is this true:



1. New record is inserted into the DataSet.

2. Newly inserted record is modified in the DataSet.

3. DataAdapter.Update() is called.



If that's the case, this is not going to work as Update command would be
selected for this row which would fail since you do not have row to update
in the DB.

If you need to modify row in inserted state, consider deleting it and
inserting again with new data.


Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
R

Raja

Hi,

The scenario is as follows:

1)New record inserted in to Dataset

2)Adapter.Updated called

3)Dataset accepts changes and gets the key of the inserted row and
updates its primary key


4)User selects inserted row from datagrid

5) Row selected from Dataset (I verified the id of the row being
modified .It has the key which was returned during inserted).

6)Row modified in Dataset

7)Adapter.Update called


8)Fails here giving concurrency violation.


Thanks,

Raja
 

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