Article ID: 142216
Article Last Modified on 7/1/2004
Hkey_Current_User/Software/ODBC/ODBC.INIExample 1:
* Code to create a new datasource for an Excel file.
*
* First you need to use the Declare DLL function to prototype the
* SQLConfigDataSource function
***
DECLARE Integer SQLConfigDataSource in odbccp32.dll Integer, Integer,;
String, String
***
* Now you need to create a string containing the settings appropriate
* to the driver you are using.. the following is an example for a tier 1
* Microsoft Excel ODBC driver accessing the Schedule.xls file.
***
settings="DSN=NewExcelDataSource"+chr(0)+;
"Description=NewExcel Description"+chr(0)+;
"FileType=Excel 5.0"+chr(0)+;
"DBQ=C:\schedule.xls"+chr(0)+;
"MaxScanRows=16"
* Note: If you have spaces on either side of the equal sign (=), this
* code will not work.
? SQLConfigDataSource(0,1,"Microsoft Excel Driver (*.xls)",settings)
***
Example 2:
* Code to create a new datasource to a VFP table.
*
* First you need to use the Declare DLL function to prototype the
* SQLConfigDataSource function
***
DECLARE Integer SQLConfigDataSource in odbccp32.dll Integer, ;
Integer, String, String
***
* Now you need to create a string containing the settings appropriate
* to the driver you are using. The following is an example for the
* Microsoft VFP ODBC driver accessing the customer.dbf file.
***
settings="DSN=VFP Tables"+chr(0)+;
"Description=VFP ODBC Driver"+chr(0)+;
"SourceDB=c:\vfp\samples\data\customer.dbf"+chr(0)+;
"SourceType=DBF"
* Note: If you have spaces on either side of the equal sign (=), this
* code will not work.
? SQLConfigDataSource(0,1,"Microsoft Visual FoxPro Driver",settings)
***
* Now you can create a view to these datasources either through the view
* designer or in code.
***
Additional query words: ODBC SQLCONFIGDATASOURCE
Keywords: kbhowto kbcode KB142216