# ODBC--call failed - Client Cursor: 12 - No key columns are specified for the update t



## amrizvi (Jun 21, 2011)

IN VBA, 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 error details is 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

```
[FONT=Tahoma][SIZE=1]Function m_Dbase_ODBC_Adding()[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]On Error GoTo mTrap_Error[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]Dim mWorkODBC As Workspace[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]Dim mRstSource As Recordset[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]Dim mSerCon As Connection[/SIZE][/FONT]
 
[FONT=Tahoma][SIZE=1]'Workspace[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]Set mWorkODBC = CreateWorkspace("", "admin", "", dbUseODBC)[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]mWorkODBC.DefaultCursorDriver = dbUseClientBatchCursor[/SIZE][/FONT]
 
[FONT=Tahoma][SIZE=1]'Connection[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]Set mSerCon = mWorkODBC.OpenConnection("", , , _[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]  "ODBC;DSN=dBASE Files")[/SIZE][/FONT]
 
[FONT=Tahoma][SIZE=1]Set mRstSource = mSerCon.OpenRecordset("SELECT EMPID, EMPNAME, EMPDEPT, EMPSALARY FROM EMPLOYEE", dbOpenDynaset, 0, dbOptimisticBatch)[/SIZE][/FONT]
 
[FONT=Tahoma][SIZE=1]With mRstSource[/SIZE][/FONT]
 
 
 
[FONT=Tahoma][SIZE=1]            .AddNew[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]            !EMPID = 20[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]            !EMPNAME = "Staff 20"[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]            !EMPDEPT = "Accounts"[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]            !EMPSALARY = 2000[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]            .Update[/SIZE][/FONT]
 
[FONT=Tahoma][SIZE=1]            'Add Second Record[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]            .AddNew[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]            !EMPID = 21[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]            !EMPNAME = "Staff 21"[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]            !EMPDEPT = "Sales"[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]            !EMPSALARY = 2100[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]            .Update[/SIZE][/FONT]
 
[FONT=Tahoma][SIZE=1]    .Update dbUpdateBatch[/SIZE][/FONT]
 
[FONT=Tahoma][SIZE=1]    Debug.Print .BatchCollisionCount[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]End With[/SIZE][/FONT]
 
[FONT=Tahoma][SIZE=1]mRstSource.Close[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]Set mWorkODBC = Nothing[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]Exit Function[/SIZE][/FONT]
 
[FONT=Tahoma][SIZE=1]' Error Trap here and Exit[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]mTrap_Error:[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]Dim errObject As DAO.Error[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]Dim strError As String[/SIZE][/FONT]
 
[FONT=Tahoma][SIZE=1]If DBEngine.Errors.Count > 0 Then[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]    For Each errObject In DBEngine.Errors[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]        strError = strError & "DAO Error " & _[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]        errObject.Number & ": " & _[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]        errObject.Description & vbCrLf[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]    Next errObject[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]    Debug.Print strError[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]End If[/SIZE][/FONT]
[FONT=Tahoma][SIZE=1]End Function[/SIZE][/FONT]
```


----------



## Ninjaboi (Dec 27, 2010)

Hello amritzvi, welcome to TSF!

This MSDN link sums up the problem for you.

No key columns specified for the update table "name". Use the KeyFieldList property of the cursor (Error 1492)(Visual FoxPro Error Message)



> Modify the KeyFieldList property to include key columns for each table that is being updated. The key fields also need to be included in the UpdateNameList property. For most views, you can use the View Designer to set the view update properties and then save the view back into the database. For more information, see CURSORGETPROP( ).


----------



## amrizvi (Jun 21, 2011)

Ninjaboi said:


> Hello amritzvi, welcome to TSF!
> 
> This MSDN link sums up the problem for you.
> 
> No key columns specified for the update table "name". Use the KeyFieldList property of the cursor (Error 1492)(Visual FoxPro Error Message)


Thanks Ninjaboi

But I am not very much fimilliar with .NET and the above resolution is only for .NET, I need it for VBA, please send something for same if you get.

Thx anyway.


----------

