Click to See Complete Forum and Search --> : concurrency Violation affected 0 of the expected


psionman
July 23rd, 2009, 10:04 AM
I am using ado.net to update a simple table. Single user so no conflicts

Select, Insert and Update work fine, when I try to delete I get the concurrency Violation message

My code is:

<code>
Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
Dim sSqlDelete As String
Dim cmdDelete As SqlCommand

Try
sSqlDelete = "DELETE FROM AAA WHERE Format_ID = '@Format_ID'"

cmdDelete = New SqlCommand(sSqlDelete, sqlCon)
With cmdDelete.Parameters
.Add("@Format_ID", SqlDbType.NVarChar, 16, "Format_ID")
End With
oAdapter.DeleteCommand = cmdDelete
dsDataSet.Tables("AAA").Rows(0).Delete()
oAdapter.Update(dsDataSet, "AAA")
Catch ex As SqlException
MsgBox("Error: " & ex.ToString())
End Try
MsgBox("Deleted", , vbInformation)
End Sub
</code>

The error occurs on the oAdapter.Update statement

Can anyone please help?