Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC Failed - No key columns are specified for the update table

Status
Not open for further replies.

amrizvi

Programmer
Jun 21, 2011
8
0
0
AE
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
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

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top