Using the Connectivity Kit to Access a Btrieve Database
ID: Q115837
|
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 Btrieve database.
MORE INFORMATION
This article assumes that you have the Btrieve 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 Btrieve data source, you must do the following:
- Obtain WBTRCALL.DLL from Btrieve. This file is part of the Btrieve for
Windows product. The above DLL must be installed and accessible on the
system.
- Install the Btrieve ODBC Driver and set up a Btrieve data source through
the ODBC Btrieve 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.
- Make sure a Btrieve Data Definition File (DDF) is in the Btrieve data
directory and make sure it points to the data files correctly (the paths
to the Btrieve data files are hard-coded in the DDF).
The following is a code sample that "connects" to a Btrieve data source:
*-- Connect to a Btrieve data source
PRIVATE lcSource, lcUser, lcPwd, hDBHdle, lnDBRes
*-- Init memvars
STORE 0 TO hDBHdle, lnDBRes
lcSource = "Btrieve" && Btrieve data source name from ODBC dialog
lcUser = "" && Not needed for single-tier drivers
lcPwd = "" && Normally not needed for Btrieve
*-- 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 Btrieve - Handle:"+STR(hDBHdle,1,0) TIMEOUT 2
ELSE
WAIT WINDOW ;
"Unable to connect to Btrieve .."
ENDIF
NOTE: The Connectivity Kit can return a valid connection handle to FoxPro
even if no Btrieve DDF file exists. Without a DDF file, however, nothing
else can be accomplished, because the Connectivity Kit has no way of
knowing what tables/columns are contained in the Btrieve *.DAT files.
If the Btrieve data source does not point to a specific directory (because
Use Current Directory was selected in the Setup dialog box), you can use
the following DBExec() command to specify the desired directory:
lnDbRes = DBExec(hDBHdle, "use f:\odbcdata\btrieve")
*(change drive and directory to suit)
Btrieve is manufactured by Btrieve Technologies, Inc., a vendor independent
of Microsoft; we make no warranty, implied or otherwise, regarding this
product's performance or reliability.
REFERENCES
Microsoft ODBC Desktop Database Driver Kit Btrieve Driver online Help file
Additional query words:
FoxWin 2.50 ck betrieve
Keywords : kbcode FxtoolCk
Version : 2.50 2.50a 2.50b 2.60
Platform : WINDOWS
Issue type :
|