Microsoft KB Archive/117243

{|
 * width="100%"|

-

The information in this article applies to:


 * Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6
 * Microsoft FoxPro Connectivity Kit, versions 2.5, 2.6

-

SUMMARY
This article describes how to use the FoxPro Connectivity Kit and ODBC to access data that resides in a dBASE database.

NOTE: dBASE is manufactured by a vendor independent of Microsoft; we make no warranty, implied or otherwise, regarding this product's performance or reliability.

MORE INFORMATION
This article assumes that you have the dBASE ODBC driver that is available as a part of the Microsoft ODBC Desktop Database Driver Kit (DDDK). This driver is also included with some Microsoft products, such as Microsoft Word for Windows and Microsoft Excel for Windows. To connect to a dBASE data source, you must install the dBASE ODBC Driver and set up a dBASE data source through the ODBC dBASE Setup dialog box in the Windows Control Panel. Since this is a level 1 ODBC driver, the data source is a directory name or the current directory, as indicated in the Setup dialog box.

The dBASE ODBC Setup dialog box also contains an Index dialog box that allows you to associate indexes with a particular .DBF file. A dBASE .MDX file should automatically be used if present.

The following is a code sample that "connects" to a dBASE data source:

  *-- Connect to a dBASE Data Source PRIVATE lcSource, lcUser, lcPwd, hDBHdle, lnDBRes

*-- Init memvars STORE 0 TO hDBHdle, lnDBRes lcSource = "dBASE"     && dBASE Data Source Name from ODBC dialog box lcUser = ""         && Not needed for single tier drivers lcPwd = ""         && Not needed for dBASE

*-- Load Library if not already IF !"FPSQL" $ SET('library') SET LIBRARY TO FPSQL.FLL ENDIF WAIT WINDOW "Attempting connection ..." NOWAIT hDBHdle = dbConnect(lcSource, lcUser, lcPwd, "") IF hDBHdle > 0 WAIT WINDOW ; "Connected to dBASE - Handle:"+STR(hDBHdle,1,0) TIMEOUT 2 ELSE WAIT WINDOW ; "Unable to connect to dBASE .." ENDIF If the dBASE data source does not point to a specific directory (Use Current Directory is selected in the Setup dialog box), the following DBExec command will place the user in the desired directory:   lnDbRes = DBExec(hDBHdle, "USE f:\smpldata\dbase") *(change drive, directory and database name to suit)