System.Data.DBConcurrencyException
From: MichaelZeno (MichaelZeno_at_discussions.microsoft.com)
Date: 09/24/04
- Previous message: dormy: "Reducing Number of Columns When Changing Query"
- Next in thread: Val Mazur: "Re: System.Data.DBConcurrencyException"
- Reply: Val Mazur: "Re: System.Data.DBConcurrencyException"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 24 Sep 2004 13:07:11 -0700
I am having an intermittent problem in updating a SQL database from a web
form. On some records, my web application ends with a
"System.Data.DBConcurrencyException" error. The message is "Concurrency
violation: the UpdateCommand affected 0 records".
My update command is "Me.SqlUpdateCommand1.CommandText = "UPDATE
dbo.Employee SET ID = @ID, LastName = @LastName, FirstName = @FirstName, W" &
_
"orkPhone = @WorkPhone, RoomNumber = @RoomNumber, UpdateTime =
@UpdateTime WHERE " & _
"(ID = @Original_ID) AND (FirstName = @Original_FirstName) AND
(LastName = @Origi" & _
"nal_LastName) AND (RoomNumber = @Original_RoomNumber) AND
(UpdateTime = @Origina" & _
"l_UpdateTime) AND (WorkPhone = @Original_WorkPhone); SELECT ID,
LastName, FirstN" & _
"ame, WorkPhone, RoomNumber, UpdateTime FROM dbo.Employee WHERE (ID
= @ID)" This was generated by the .NET studio IDE, when I created a
dataadapter, using the tool bar.
dsEmployee1 is my dataset, and I am taking values from textboxes, and moving
them to the row items, then invoking the Update command in my data adapter.
My code for update is:
If IsPostBack Then
If dsEmployee1.HasErrors Then
lblMessage.Text = "There was an error in updating the Phone
List." & _
dsEmployee1.Tables("Employee").Rows("0").RowError
Else
Try
daEmployee1.Update(dsEmployee1, "Employee")
lblMessage.Text = "The Phone List Has Been Updated."
txtFirstName.Enabled = False
txtLastName.Enabled = False
txtWorkPhone.Enabled = False
txtRoomNumber.Enabled = False
Catch ex2 As DBConcurrencyException
Response.Write(ex2)
Catch ex As Exception
Response.Write(ex)
End Try
End If
End If
This problem only occurs on 1 in 10 records. My DBA believes that some how,
after I inserted the record, it was not committed to the database. I have a
"connection.close()" on the Insert statement (in another program). Any help
would be appreciated. Thanks.
- Previous message: dormy: "Reducing Number of Columns When Changing Query"
- Next in thread: Val Mazur: "Re: System.Data.DBConcurrencyException"
- Reply: Val Mazur: "Re: System.Data.DBConcurrencyException"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|