System.Data.DBConcurrencyException

From: MichaelZeno (MichaelZeno_at_discussions.microsoft.com)
Date: 09/24/04

  • Next message: Dave_at_LAD: "Can't create hyperlink with ADOX"
    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.


  • Next message: Dave_at_LAD: "Can't create hyperlink with ADOX"

    Relevant Pages

    • Updating a SQL database
      ... Subject: Updating a SQL database 5/5/2004 10:55 PM PST ... What I have is a form that has text fields populated from a SQL database. ... I'm changing the text in them to trigger a 'change' so the update command will work. ... Hi Amber: ...
      (microsoft.public.dotnet.languages.vb)
    • Re: System.Data.DBConcurrencyException
      ... Val Mazur ... "MichaelZeno" wrote in message ... >I am having an intermittent problem in updating a SQL database from a web ...
      (microsoft.public.data.ado)
    • Q: Slow update
      ... I hope you'll forgive me for posting this here (I've also posted to ado site ... but with no response so far) as I'm urgently after a solution. ... the table in a DataSet and I want to update it to the SQL database which the ... I'm using a data adaptor and the update command ...
      (microsoft.public.dotnet.languages.vb)
    • Re: Updating a specific cell in a SQL database
      ... already-created row in a SQL database. ... therefore I cannot edit information. ... you're looking for the UPDATE command, ...
      (microsoft.public.dotnet.languages.vb)