Microsoft KB Archive/294469

= PRB: Error &quot;Cannot Update the Cursor&quot; When You Modify Visual FoxPro Tables =

Article ID: 294469

Article Last Modified on 10/17/2001

-

APPLIES TO


 * Microsoft Open Database Connectivity Driver for Visual FoxPro 5.0

-



This article was previously published under Q294469



SYMPTOMS
You can use the Execute Action Query option to manipulate data in database tables. When you execute SQL Action queries (such as INSERT, UPDATE or DELETE) on a Visual FoxPro table, you may receive the following error message:

Run-time error '-2147467259 (80004005)':

[Microsoft][ODBC Visual FoxPro Driver]Cannot update the cursor.



CAUSE
This error occurs if you select the Read-Only check box for the Visual FoxPro file. To review the file attributes, right-click the Visual FoxPro file, click Properties, and then click the General tab.



RESOLUTION
To resolve this problem, make sure that you clear Read-Only check box for the Visual FoxPro file.



MORE INFORMATION
You can use the Execute method (with Data Access Object or Microsoft ActiveX Data Objects libraries, for example) to execute Action queries on the Connection object. The following sample code uses the ActiveX Data Objects (ADO) library to reproduce the above-mentioned error. The sample code creates a test Visual FoxPro table named T1.Dbf, and then uses the INSERT SQL Action Query to add records.

Steps to Reproduce Behavior
 Open a new Visual Basic standard EXE project. Form1 is created by default. Set a reference to the Microsoft ActiveX Data Objects library. Place two command buttons (CreateTable and ADOExecute) on Form1.  Add the following code to Form1: Dim conADO As ADODB.Connection

Private Sub CreateTable_Click

conADO.Execute &quot;CREATE TABLE T1 (col1 Int, col2 Int)&quot;,, adExecuteNoRecords MsgBox &quot;FoxPro file created.&quot; End Sub

Private Sub Form_Load Dim strCon As String CreateTable.Caption = &quot;Create FoxPro File&quot; ADOExecute.Caption = &quot;Execute Action Query&quot; strCon = &quot;Driver={Microsoft Visual FoxPro Driver};&quot; & _ &quot;SourceType=DBF;&quot; & _ &quot;SourceDB=&quot; & App.Path & &quot;\;&quot; & _ &quot;Exclusive=No;&quot; Set conADO = New ADODB.Connection conADO.Open strCon

End Sub

Private Sub ADOExecute_Click Dim strSQL As String Dim numRec As Integer strSQL = &quot;Insert Into T1 values(1,100)&quot;

conADO.Execute strSQL, numRec, adExecuteNoRecords MsgBox &quot;Records Affected = &quot; & numRec End Sub

Private Sub Form_Unload(Cancel As Integer) conADO.Close Set conADO = Nothing

End Sub  Run the project, and then click Create FoxPro File. Click Execute Action Query, and notice that it executes successfully.</li> Select the Read-Only check box for the T1.dbf file.</li> Click Execute Action Query again, and you receive the above-mentioned error.</li></ol>

Additional query words: -2147467259 (80004005)

Keywords: kbprb KB294469

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.