Re: System.Data.DBConcurrencyException
From: Val Mazur (group51a_at_hotmail.com)
Date: 09/25/04
- Next message: JochenZ: "updating DataTable using DataGrid"
- Previous message: Val Mazur: "Re: Update Database from DataAdapter"
- In reply to: MichaelZeno: "System.Data.DBConcurrencyException"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 24 Sep 2004 23:35:15 -0400
Hi,
Could be similar to what described in next KB. When if you connection does
not use SET NOCOUNT ON in a current session
http://support.microsoft.com/default.aspx?scid=kb;en-us;310375&Product=adonet
--
Val Mazur
Microsoft MVP
"MichaelZeno" <MichaelZeno@discussions.microsoft.com> wrote in message
news:F7043468-DEA7-4E23-8DB3-24335A67B57F@microsoft.com...
>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.
>
- Next message: JochenZ: "updating DataTable using DataGrid"
- Previous message: Val Mazur: "Re: Update Database from DataAdapter"
- In reply to: MichaelZeno: "System.Data.DBConcurrencyException"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|