How to Use SQL Pass Through to Connect to ASCII Text FilesLast reviewed: February 20, 1996Article ID: Q146224 |
The information in this article applies to:
SUMMARYThis article shows by example how to use Visual FoxPro and ODBC to access data that resides in ASCII text files.
MORE INFORMATIONFor Visual FoxPro 3.0b, the ODBC drivers for Windows 95, Windows NT, and Windows 3.1x are included with the product. For Visual FoxPro 3.0, ODBC drivers for Windows NT and Windows 3.1x are included. The ODBC drivers for Visual FoxPro 3.0 and Windows 95 are available as an Application Note titled "Microsoft ODBC Drivers for 32-Bit Programs" (GE1263). For more information about GE1263, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q140255 TITLE : GE1263: Microsoft ODBC Drivers for 32-Bit Programs Step-by-Step ExampleThis example demonstrates how to connect to a text file by using ODBC from Visual FoxPro.
NotesWhen a directory is selected in the ODBC Text Setup dialog box, column information is saved in a file in that directory called Schema.ini. There is a section in this file for each file in the specified directory that matches the extensions in the File Extensions list (visible when the Options button is clicked). The Schema.ini section for the Customer.csv file used in the previous example appears as follows:
[customer.csv] ColNameHeader=False Format=CSVDelimited MaxScanRows=25 CharacterSet=OEM Col1=F1 Char Width 254 Col2=F2 Char Width 254 Col3=F3 Char Width 254 Col4=F4 Char Width 254 Col5=F5 Char Width 254 Col6=F6 Char Width 254 Col7=F7 Char Width 254 Col8=F8 Char Width 254 Col9=F9 Char Width 254 Col10=F10 Char Width 254 Col11=F11 Char Width 254 Col12=F12 FloatThe correct column names and field lengths and from the Customer table (obtained with a LIST STRUCTURE command) can be used to modify the Schema.ini file as follows to allow correct column names and widths to appear in Visual FoxPro. These modifications can also be made through the Define Text Format dialog box.
[customer.csv] ColNameHeader=False Format=CSVDelimited MaxScanRows=25 CharacterSet=OEM Col1=CUST_ID Char Width 6 Col2=COMPANY Char Width 40 Col3=CONTACT Char Width 30 Col4=TITLE Char Width 30 Col5=ADDRESS Char Width 60 Col6=CITY Char Width 15 Col7=REGION Char Width 15 Col8=POSTALCODE Char Width 10 Col9=COUNTRY Char Width 15 Col10=PHONE Char Width 24 Col11=FAX Char Width 24 Col12=MAXORDAMT FloatThe Text File driver supports the SQL SELECT and INSERT commands only, not DELETE or UPDATE. This prevents deleting or modifying existing records. The maximum width of a column of Character data can be set in Visual FoxPro in the Remote Data tab of the Options dialog box. The setting in the "Use Memo for Fields >=:" spinner determines this maximum width. The default value (also the absolute maximum) for this setting is 255. If this maximum width setting is exceeded, the data is brought in as Memo data instead of Character data.
|
Additional reference words: 3.00 3.00b SPT VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |