L
Lee Ottaway
I have read various threads relating to concurrency issues in ADO.NET
and thought when I implemented the info I found that my problems would
be solved, however I'm still getting concurrency issues. Can anyone
tell me what's wrong with this code:
This is the DataAdapter handler I've implemented to get the Primary
Key information from the AutoIncremented field 'ID' for new records in
my single table called tblStaff:
Private Sub HandleUpdate(ByVal sender As Object, ByVal e As
OleDbRowUpdatedEventArgs) Handles madp.RowUpdated
If e.StatementType = StatementType.Insert Then
Dim getKey As New OleDbCommand("SELECT @@IDENTITY", gCon)
e.Row("ID") = getKey.ExecuteScalar
getKey.Dispose()
End If
End Sub
I can then add a record with no problem and the e.Row("ID") is getting
the correct value for the ID. However, when I edit and update the
same record with the following:
Dim frm As New frmStaffDlg()
Dim dv As New DataView(mds.Tables("tblStaff"))
Dim row As DataRowView
row = dv.AddNew()
frm.DataRowView = row
If frm.ShowDialog() = DialogResult.OK Then
madp.Update(mds, "tblStaff")
mds.AcceptChanges()
End If
It comes up with a concurrency issue and tells me no records have been
updated. The strange thing is that the ID is correct in the
dataset.tables("tblStaff").Columns("ID"). What on earth am I doing
wrong???
I'm using Access 2002 by the way so I know there's no problem with the
"SELECT @@IDENTITY" CALL.
and thought when I implemented the info I found that my problems would
be solved, however I'm still getting concurrency issues. Can anyone
tell me what's wrong with this code:
This is the DataAdapter handler I've implemented to get the Primary
Key information from the AutoIncremented field 'ID' for new records in
my single table called tblStaff:
Private Sub HandleUpdate(ByVal sender As Object, ByVal e As
OleDbRowUpdatedEventArgs) Handles madp.RowUpdated
If e.StatementType = StatementType.Insert Then
Dim getKey As New OleDbCommand("SELECT @@IDENTITY", gCon)
e.Row("ID") = getKey.ExecuteScalar
getKey.Dispose()
End If
End Sub
I can then add a record with no problem and the e.Row("ID") is getting
the correct value for the ID. However, when I edit and update the
same record with the following:
Dim frm As New frmStaffDlg()
Dim dv As New DataView(mds.Tables("tblStaff"))
Dim row As DataRowView
row = dv.AddNew()
frm.DataRowView = row
If frm.ShowDialog() = DialogResult.OK Then
madp.Update(mds, "tblStaff")
mds.AcceptChanges()
End If
It comes up with a concurrency issue and tells me no records have been
updated. The strange thing is that the ID is correct in the
dataset.tables("tblStaff").Columns("ID"). What on earth am I doing
wrong???
I'm using Access 2002 by the way so I know there's no problem with the
"SELECT @@IDENTITY" CALL.