PC Review


Reply
Thread Tools Rate Thread

Concurrency Violation Exception

 
 
Tom Jorgenson
Guest
Posts: n/a
 
      9th Dec 2003
I'm using disconnected datasets in an ASP.NET web application. I'm using the
automatic locking (that is, I'm not doing anything myself to cause a lock
other than calling an update).

When I go to persist a change in a dataset, it generates a concurrency
violation exception.

The only problem is that I'm the only user of the SQL Server (as well as the
database and table) and this is the FIRST update that's been applied to the
table during this session. This isn't even a new record in the table (or I
might suspect getting caught somehow by a default entry).

So, how can I get a concurrency violation on a table record that couldn't
have been modified after the dataset was originally loaded?

Another question, is it true that the lock (in automatic locking) is applied
only during the update? Could the record somehow have remained locked in the
table even after the session has died? If so, how can it be released
manually?

I'm stumped.


 
Reply With Quote
 
 
 
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      9th Dec 2003
I suspect that the exception being raised is telling you that ADO.NET
"thinks" there is a concurrency violation. When an Update method is
executed, ADO.NET expects to hear back from the server that 1 row (and only
1 row) was affected. If something went wrong during the Update (someone
changed the row after you read it, the row was deleted, or anything that
would change the RowsAffected value) ADO.NET will throw a "concurrency"
exception.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Tom Jorgenson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm using disconnected datasets in an ASP.NET web application. I'm using

the
> automatic locking (that is, I'm not doing anything myself to cause a lock
> other than calling an update).
>
> When I go to persist a change in a dataset, it generates a concurrency
> violation exception.
>
> The only problem is that I'm the only user of the SQL Server (as well as

the
> database and table) and this is the FIRST update that's been applied to

the
> table during this session. This isn't even a new record in the table (or I
> might suspect getting caught somehow by a default entry).
>
> So, how can I get a concurrency violation on a table record that couldn't
> have been modified after the dataset was originally loaded?
>
> Another question, is it true that the lock (in automatic locking) is

applied
> only during the update? Could the record somehow have remained locked in

the
> table even after the session has died? If so, how can it be released
> manually?
>
> I'm stumped.
>
>



 
Reply With Quote
 
Miha Markic
Guest
Posts: n/a
 
      9th Dec 2003
In addition to Bill, can you show us your adapter (including commands) code?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Tom Jorgenson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm using disconnected datasets in an ASP.NET web application. I'm using

the
> automatic locking (that is, I'm not doing anything myself to cause a lock
> other than calling an update).
>
> When I go to persist a change in a dataset, it generates a concurrency
> violation exception.
>
> The only problem is that I'm the only user of the SQL Server (as well as

the
> database and table) and this is the FIRST update that's been applied to

the
> table during this session. This isn't even a new record in the table (or I
> might suspect getting caught somehow by a default entry).
>
> So, how can I get a concurrency violation on a table record that couldn't
> have been modified after the dataset was originally loaded?
>
> Another question, is it true that the lock (in automatic locking) is

applied
> only during the update? Could the record somehow have remained locked in

the
> table even after the session has died? If so, how can it be released
> manually?
>
> I'm stumped.
>
>



 
Reply With Quote
 
Tom Jorgenson
Guest
Posts: n/a
 
      9th Dec 2003
this.sqlDataAdapterYouth = new System.Data.SqlClient.SqlDataAdapter();

//
// sqlDataAdapterYouth
//
this.sqlDataAdapterYouth.DeleteCommand = this.sqlDeleteCommandYouth;
this.sqlDataAdapterYouth.InsertCommand = this.sqlInsertCommandYouth;
this.sqlDataAdapterYouth.SelectCommand = this.sqlSelectCommandYouth;
this.sqlDataAdapterYouth.TableMappings.AddRange(new
System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "YOUTH", new
System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("youthID", "youthID"),
new System.Data.Common.DataColumnMapping("firstName", "firstName"),
new System.Data.Common.DataColumnMapping("initial", "initial"),
new System.Data.Common.DataColumnMapping("lastName", "lastName"),
new System.Data.Common.DataColumnMapping("dateOfBirth",
"dateOfBirth"),
new System.Data.Common.DataColumnMapping("socialSecurity",
"socialSecurity"),
new System.Data.Common.DataColumnMapping("streetAddress1",
"streetAddress1"),
new System.Data.Common.DataColumnMapping("streetAddress2",
"streetAddress2"),
new System.Data.Common.DataColumnMapping("city", "city"),
new System.Data.Common.DataColumnMapping("state", "state"),
new System.Data.Common.DataColumnMapping("zip", "zip"),
new System.Data.Common.DataColumnMapping("gender", "gender"),
new System.Data.Common.DataColumnMapping("emailAddress",
"emailAddress"),
new System.Data.Common.DataColumnMapping("ethnicity", "ethnicity"),
new System.Data.Common.DataColumnMapping("religion", "religion"),
new System.Data.Common.DataColumnMapping("familyEconomicStatus",
"familyEconomicStatus"),
new System.Data.Common.DataColumnMapping("homeAtAdmission",
"homeAtAdmission"),
new System.Data.Common.DataColumnMapping("problemSchoolBehavior",
"problemSchoolBehavior"),
new System.Data.Common.DataColumnMapping("poorAcademics",
"poorAcademics"),
new System.Data.Common.DataColumnMapping("runAlways", "runAlways"),
new System.Data.Common.DataColumnMapping("poorRelationships",
"poorRelationships"),
new System.Data.Common.DataColumnMapping("lyingOrCheating",
"lyingOrCheating"),
new System.Data.Common.DataColumnMapping("defianceOrAggression",
"defianceOrAggression"),
new System.Data.Common.DataColumnMapping("lackOfImpulseControl",
"lackOfImpulseControl"),
new System.Data.Common.DataColumnMapping("hyperactivity",
"hyperactivity"),
new System.Data.Common.DataColumnMapping("drugEnvironment",
"drugEnvironment"),
new System.Data.Common.DataColumnMapping("alcoholEnvironment",
"alcoholEnvironment"),
new System.Data.Common.DataColumnMapping("criminalInvolvement",
"criminalInvolvement"),
new System.Data.Common.DataColumnMapping("notApplicable",
"notApplicable"),
new System.Data.Common.DataColumnMapping("singleParent",
"singleParent"),
new System.Data.Common.DataColumnMapping("neglected", "neglected"),
new System.Data.Common.DataColumnMapping("abused", "abused"),
new System.Data.Common.DataColumnMapping("abandoned", "abandoned"),
new System.Data.Common.DataColumnMapping("noSupervisionOrControl",
"noSupervisionOrControl"),
new System.Data.Common.DataColumnMapping("alcoholicAddictedParent",
"alcoholicAddictedParent"),
new System.Data.Common.DataColumnMapping("disabledParent",
"disabledParent"),
new System.Data.Common.DataColumnMapping("incomeBelowPoverty",
"incomeBelowPoverty"),
new System.Data.Common.DataColumnMapping("unsafeNeighborhood",
"unsafeNeighborhood"),
new System.Data.Common.DataColumnMapping("educationOpportunities",
"educationOpportunities"),
new System.Data.Common.DataColumnMapping("other", "other"),
new System.Data.Common.DataColumnMapping("socialNotApplicable",
"socialNotApplicable")})});
this.sqlDataAdapterYouth.UpdateCommand = this.sqlUpdateCommandYouth;




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Miha Markic
Guest
Posts: n/a
 
      9th Dec 2003
Hi Tom,

I would like to see commands definitions.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Tom Jorgenson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> this.sqlDataAdapterYouth = new System.Data.SqlClient.SqlDataAdapter();
>
> //
> // sqlDataAdapterYouth
> //
> this.sqlDataAdapterYouth.DeleteCommand = this.sqlDeleteCommandYouth;
> this.sqlDataAdapterYouth.InsertCommand = this.sqlInsertCommandYouth;
> this.sqlDataAdapterYouth.SelectCommand = this.sqlSelectCommandYouth;



 
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
Yet another "Concurrency violation: the UpdateCommand affected 0 records" exception Santi Microsoft ADO .NET 2 23rd Feb 2007 06:08 PM
concurrency violation Kevin Cabral via .NET 247 Microsoft ADO .NET 0 31st Oct 2004 11:49 AM
RE: concurrency violation =?Utf-8?B?bWtsYXBw?= Microsoft ADO .NET 0 18th Oct 2004 04:19 PM
HELP: Concurrency violation exception and IDENTITY columns mitmed Microsoft ADO .NET 0 27th May 2004 07:48 AM
Concurrency violation Raymond Microsoft ADO .NET 4 5th Nov 2003 04:33 PM


Features
 

Advertising
 

Newsgroups
 


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