ODBC FAILED / No key columns are specified for the update table

amrizvi

New member
Local time
Today, 23:59
Joined
Jun 21, 2011
Messages
6
I am trying to Add two records in {Dbase III DBF file connected through ODBC} by using batch update in order to handle the Collision in multiusers environment.
BUT receiving following error “ODBC--call failed.” on line dbUpdateBatch
Details errors are as below:
DAO Error 12: Client Cursor: 12 - No key columns are specified for the update table
DAO Error 3146: ODBC--call failed.
NOTE : Result is OK if add one record and use dbUpdateBatch
Function m_Dbase_ODBC_Adding()
On Error GoTo mTrap_Error
Dim mWorkODBC As Workspace
Dim mRstSource As Recordset, mRstTarget As Recordset
Dim mSerCon As Connection

'Workspace
Set mWorkODBC = CreateWorkspace("", "admin", "", dbUseODBC)
mWorkODBC.DefaultCursorDriver = dbUseClientBatchCursor

'Connection
Set mSerCon = mWorkODBC.OpenConnection("", , , _
"ODBC;DSN=dBASE Files")

Set mRstSource = mSerCon.OpenRecordset("SELECT EMPID, EMPNAME, EMPDEPT, EMPSALARY FROM EMPLOYEE", dbOpenDynaset, 0, dbOptimisticBatch)

With mRstSource
Rem .UpdateOptions = dbCriteriaUpdate + dbCriteriaKey


Do While Not .EOF
If !EMPID = 1 Then
.AddNew
!EMPID = 20
!EMPNAME = "Staff 20"
!EMPDEPT = "Accounts"
!EMPSALARY = 2000
.Update

'Add Second Record
.AddNew
!EMPID = 21
!EMPNAME = "Staff 21"
!EMPDEPT = "Sales"
!EMPSALARY = 2100
.Update

End If
.MoveNext
Loop

.Update dbUpdateBatch
Debug.Print .BatchCollisionCount
End With

mRstSource.Close
Set mWorkODBC = Nothing
Exit Function

'' Error Trap here and Exit
mTrap_Error:
Dim errObject As DAO.Error
Dim strError As String

If DBEngine.Errors.Count > 0 Then
For Each errObject In DBEngine.Errors
strError = strError & "DAO Error " & _
errObject.Number & ": " & _
errObject.Description & vbCrLf
Next errObject
Debug.Print strError
End If
End Function
 

Users who are viewing this thread

Back
Top Bottom