Microsoft KB Archive/146220

= PRB: The ODBC Text File Driver Only Supports INSERT Statement =

Article ID: 146220

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Data Access Components 2.5
 * Microsoft Data Access Components 2.6

-



This article was previously published under Q146220



SYMPTOMS
In a scenario where a cursor is open from a Remote View or SQL Pass Through connection made through the Text File ODBC driver, if you try to modify or delete a record in that cursor, one of the following errors occurs:

Connectivity error: [Microsoft][ODBC Text Driver] Deleting data in an attached (or linked) table not supported by this ISAM.

-or-

Connectivity error: [Microsoft][ODBC Text Driver] Updating data in an attached (or linked) table not supported by this ISAM.



CAUSE
The Text File ODBC driver does not support the SQL DELETE or UPDATE statements.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Create a comma-delimited text file for use as the data source for the ODBC driver by typing each of the following commands in the Command window (this code assumes you have installed the sample data for each version of Visual FoxPro):

  If using Visual FoxPro 3.0x or 5.0x: SET DEFAULT TO home+"samples\data" USE customer *!* Create a comma delimited Customer file COPY TO customer.csv fields cust_id, company DELIMITED USE   If using Visual FoxPro 6.0, check the setting of Samples Directory on the File Locations tab of the Options screen. You can access this from the main menu by selecting TOOLS>OPTION. It should point to the "...\samples\vfp98\>". Set this option if it is not set, then run this code from the command window: SET DEFAULT TO home(2)+"samples\data" USE customer *!* Create a comma delimited Customer file COPY TO customer.csv fields cust_id, company DELIMITED USE 

Set up a Text File data source. In Windows 3.1x, do this through the ODBC Administrator in the Visual FoxPro program group or by using the ODBC icon in the Windows Control Panel. In Windows 95, do this through the 32 ODBC Administrator located in the ODBC program group or the Control Panel. In Windows NT, do this through the 32 ODBC Administrator in the Visual FoxPro program group or the ODBC icon in Control Panel. Use the following steps to set up a Data Source for the Visual FoxPro table saved as a comma-delimited file in Step 1:  Open the ODBC or 32 Bit ODBC Administrator icon.</li> From the Add list, select Microsoft Text Driver, and click OK. The ODBC Text Setup dialog box will appear.</li> Type FoxPro Text Test in the Data Source Name, and then click the Select Directory button.</li> Select the Vfp\Samples\Data directory, and click OK.</li> Click the Options button, and then click the Define Format button.</li> In the Define Text Format dialog box, select the Customer.csv file.</li> Click the Guess button to create a Data Type, Name, and Width for each column of the selected file. Select each column, starting with F1, from the list. For each item in the list with a Data Type of Char, change the Width from 255 to the correct column width (if known). If the correct column width is not known, set each to 254 (the value used for the purposes of this example). Either way, as each column width is set, click Modify. The column width for each Char column must be set to a value less than 255 to enable the column to appear in Visual FoxPro as Character rather than Memo data.</li> When you finish, click OK in the Define Text Format dialog box, and then click OK in the OCBC Text Setup dialog box. Then click Close in the Data Sources dialog.</li></ol> </li>  Open the Testdata database by typing the following command in the Command window: MODIFY DATABASE testdata </li> Right-click in an empty area of the Database Designer, and select New Remote View. Then click the New View button.</li> Select the Available Datasources option. Then select FoxPro Text Test from the list, and click OK.</li> From the list of tables in the Open dialog box, select Customer.csv, and click OK.</li> Click the Fields tab of the View Designer, and click the Add All button.</li> Click the Update Criteria tab of the View Designer, and click the column next to the Key field (F1 in this example) beneath the Key to place a check mark there.</li> Place a check in the column under the Pencil for this same field, and click the Update All button to make all fields updatable.</li> Place a check mark in the Send SQL Updates check box.</li> Right-click in the View Designer, and select Run Query</li> <li>Edit the first record by removing the "I" from "ALFKI" in the first record. Then press the DOWN ARROW to move the record pointer. Depending on the setting in the Update Using box on the Update Criteria tab, one of the two errors will appear. If "SQL DELETE then INSERT" is selected, the first error appears, while if "SQL UPDATE" is selected, the second appears. If Revert is selected from the error dialog box, the change will be backed out and the view can be closed.</li></ol>