T
Timo
[Cross-posted to microsoft.public.access and
microsoft.public.dotnet.framework.adonet]
Since I am using JET4 SP6, I think the intermittent problem I'm
experiencing with duplicate autonumbers does not relate to the
corruption of the autonumber generator in Access after a Compact +
Repair of the MDB, because this problem was supposedly fixed by Jet4
SP4. Reference:
ACC2000: AutoNumber Field Duplicates Previous Values After You Compact
and Repair a Database (KB254708).
So I am wondering if it is possible that the SELECT @@IDENTITY command
shown below, **IF IT IS CALLED IN A TIGHT LOOP**, can have a timing
issue such that the same @@IDENTITY value is returned twice?
So, how does the SELECT @@IDENTITY command work in JET?
TIA
Timo
-----------------------
Private cmdGetIdentity As OleDb.OleDbCommand
cmdGetIdentity = New OleDb.OleDbCommand()
cmdGetIdentity.CommandText = "SELECT @@IDENTITY"
cmdGetIdentity.Connection = MyConnection
While new rows to insert
insert a row
'// fires the OnRowUpdated event (see below)
...
Private Sub OnRowUpdated(ByVal sender As Object, ByVal e As
OleDb.OleDbRowUpdatedEventArgs)
If e.Status = UpdateStatus.Continue AndAlso _
e.StatementType = StatementType.Insert Then
' Get the Identity column value and store in PK col in row
Dim IDValue as Integer
IDValue = Int32.Parse(cmdGetIdentity.ExecuteScalar().ToString)
e.Row("MyID") = IDValue
e.Row.AcceptChanges()
End If
End Sub
microsoft.public.dotnet.framework.adonet]
Since I am using JET4 SP6, I think the intermittent problem I'm
experiencing with duplicate autonumbers does not relate to the
corruption of the autonumber generator in Access after a Compact +
Repair of the MDB, because this problem was supposedly fixed by Jet4
SP4. Reference:
ACC2000: AutoNumber Field Duplicates Previous Values After You Compact
and Repair a Database (KB254708).
So I am wondering if it is possible that the SELECT @@IDENTITY command
shown below, **IF IT IS CALLED IN A TIGHT LOOP**, can have a timing
issue such that the same @@IDENTITY value is returned twice?
So, how does the SELECT @@IDENTITY command work in JET?
TIA
Timo
-----------------------
Private cmdGetIdentity As OleDb.OleDbCommand
cmdGetIdentity = New OleDb.OleDbCommand()
cmdGetIdentity.CommandText = "SELECT @@IDENTITY"
cmdGetIdentity.Connection = MyConnection
While new rows to insert
insert a row
'// fires the OnRowUpdated event (see below)
...
Private Sub OnRowUpdated(ByVal sender As Object, ByVal e As
OleDb.OleDbRowUpdatedEventArgs)
If e.Status = UpdateStatus.Continue AndAlso _
e.StatementType = StatementType.Insert Then
' Get the Identity column value and store in PK col in row
Dim IDValue as Integer
IDValue = Int32.Parse(cmdGetIdentity.ExecuteScalar().ToString)
e.Row("MyID") = IDValue
e.Row.AcceptChanges()
End If
End Sub