PC Review


Reply
Thread Tools Rate Thread

Concurrency Violations in SqlCeDataAdapter

 
 
Raja
Guest
Posts: n/a
 
      28th Nov 2005
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

 
Reply With Quote
 
 
 
 
Bart Mermuys
Guest
Posts: n/a
 
      29th Nov 2005
Hi,

"Raja" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?.


I'm not very familar with SqlCeDataAdapter, but the problem you're
describing can be caused by _not_ getting the autogenerated key from the DB
after inserting a new record.
Do you have an autogenerated primary key column ? In case you do, then are
you doing anything to get the key generated by the DB upon insert (because
the DataSet itself just uses temporal keys for inserted records) ?
If those temporal keys aren't updated with the ones actually used in the DB
then all subsequent updating or deleting will fail with a concurrency
violation.


HTH,
Greetings



>
> Thanks,
> Raja
>



 
Reply With Quote
 
Rajagopal Srirangam Srinivasan
Guest
Posts: n/a
 
      29th Nov 2005
Hi,

I am setting the readonly property of the primary key column to false and
setting the column's value to the id obtained from insert after the insert
operation.

Also I checked the value of the Primary key being passed to the adapter
update and delete commands and it seems to match with the one generated
during insert

Thanks,

Raja
 
Reply With Quote
 
Bart Mermuys
Guest
Posts: n/a
 
      29th Nov 2005
Hi,

"Rajagopal Srirangam Srinivasan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I am setting the readonly property of the primary key column to false and
> setting the column's value to the id obtained from insert after the
> insert
> operation.


Code ? Are you calling AcceptChanges after assigning the new key ?
(probely the only place were you should be calling AcceptChanges ):

someDataRow["id"] = newkey
someDataRow.AcceptChanges()

Are you using a SqlCeCommandBuilder or building the Commands yourself ?

>
> Also I checked the value of the Primary key being passed to the adapter
> update and delete commands and it seems to match with the one generated
> during insert


How did you check this ?

It looks to me that when an update or deletion of an already existing record
works, but not of a newly inserted record it must have something to do with
autogenerated key, but i could be wrong ...


HTH,
Greetings

>
> Thanks,
>
> Raja



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Handling concurrency violations John Microsoft ADO .NET 6 27th Mar 2008 06:42 PM
Handling concurrency violations John Microsoft VB .NET 6 27th Mar 2008 06:42 PM
Seemingly random Concurrency violations updating Access database mfreeman@columbus.rr.com Microsoft ADO .NET 13 29th May 2006 12:52 AM
Concurrency Violations in SqlCeDataAdapter Raja Microsoft Dot NET Compact Framework 2 29th Nov 2005 06:34 PM
SQLDataAdapter and concurrency violations STom Microsoft ADO .NET 4 24th Dec 2003 02:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:26 AM.