Re: System.Data.DBConcurrencyException

From: Val Mazur (group51a_at_hotmail.com)
Date: 09/25/04


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.
> 


Relevant Pages

  • System.Data.DBConcurrencyException
    ... I am having an intermittent problem in updating a SQL database from a web ... then invoking the Update command in my data adapter. ...
    (microsoft.public.data.ado)
  • Re: Get table and field names
    ... See next example how to do this with open method of ADO Connection ... Val Mazur ... "Kurpos" wrote in message ... > Where in a sql database can i get: ...
    (microsoft.public.vb.database.ado)
  • Re: Using ISNULL in an ADO Query for MS Jet database
    ... Val Mazur ... >I frequently use the ISNULL function when querying a SQL database like ... > I need to do the same sort of thing when querying an Access database via ...
    (microsoft.public.vb.database.ado)