Before You Begin

Before you use the add-in functions described in this chapter, you must do the following:

Installing ODBC Drivers

An ODBC driver is a dynamic-link library (DLL) that an application supporting ODBC can use to gain access to a particular DBMS, such as dBASE or Microsoft Access. The ODBC driver implements ODBC API function calls that are compatible with the SQL statements used by a particular DBMS and performs all interaction with a data source.

Installing the ODBC Drivers Provided with Word

You can install the ODBC drivers for DBMSs such as Microsoft Access, Microsoft FoxPro, Paradox, and dBASE when you install Word or any time you run the Setup program with the Custom installation option. All the provided ODBC drivers are installed unless you change the Data Access options. The ODBC drivers must be installed in your Windows System folder or in a folder recognized automatically by the operating system.

Installing Additional ODBC Drivers

To install other Microsoft or third-party ODBC drivers you purchase after installing Word, you can use the ODBC installer provided with the ODBC drivers. Install the drivers to your Windows System folder or a folder recognized automatically by the operating system.

If you've already installed at least one ODBC driver on your hard disk, you can use the ODBC Administrator program to install additional third-party ODBC drivers. (ODBC drivers provided by Word must be installed by using the Word Setup program.) To start the ODBC Administrator program, double-click the ODBC icon in the Control Panel. Then choose the Drivers button in the Data Sources dialog box.

Note

The ODBC driver you install may share some of the same dynamic-link libraries (DLLs) as other drivers installed on your computer. If so, you may be asked if you want to overwrite the driver you specified, whether or not it has been installed. Choose the Yes button to install the driver.

Setting Up Data Sources

After you install an ODBC driver, you must set up the data sources you want to access in a particular DBMS. A data source is a specific set of data in a DBMS and any information about the network or operating system (or both) needed to access the data. The following are examples of data sources:

You add, change, or delete a data source by using the ODBC Administrator program. To start the program, double-click the ODBC icon in the Control Panel or run ODBCADM.EXE (Windows 3.x) or ODBCAD32.EXE (Windows 95 and Windows NT). You can add any data source to the list in the Data Sources dialog box, providing the driver it uses is already installed on your machine.

When you add a new data source, the setup information you provide is stored
in the ODBC.INI file (Windows 3.x) or the registry (Windows 95 and Windows NT) and is used each time you access the data source. The minimum connection information typically includes the name of the data source, a user ID, and a password. Some ODBC drivers allow you to specify additional required information, such as a network address or additional passwords. For information about the connection options for a particular ODBC driver, choose the Help button in the Setup dialog box.

If you don't provide sufficient information when you set up the data source, you can provide the needed connection arguments in calls to the add-in function SQLOpen. You may also want to specify the connection string arguments to override the arguments stored during setup. If sufficient connection information is not provided in calls to SQLOpen, the ODBC driver may display a dialog box for entering the missing information, depending on the value of the DriverPrompt argument in the SQLOpen instruction.

Installing and Loading WBODBC.WLL

The ODBC extensions for WordBasic are provided in WBODBC.WLL, a Word add-in library (WLL) on the Microsoft Word Developer's Kit disk. To install the add-in library, copy the WBODBC.WLL file from the WIN16 (Windows 3.x) or WIN32 (Windows 95 and Windows NT) subfolder in the WBODBC folder to your Template folder.

Before running a macro that uses the ODBC extensions, you must load the add-in in Word. To load the add-in library, use the Templates command (File menu) to add the WBODBC.WLL to the list of global templates and add-ins. If you will frequently use the ODBC extensions in macros, you can load the add-in automatically each time you start Word by storing the WBODBC.WLL file in
the STARTUP folder in your Word program folder.

The WBODBC.DOT and INVOICE3.DOT templates in the WBODBC folder on the Microsoft Word Developer's Kit disk contain the example macros described in this appendix. Copy the templates to your Template folder to use, copy, and modify those macros. If you have installed the Microsoft Access ODBC driver provided with Word, you can copy the TEST.MDB database (also located in the WBODBC folder on the Microsoft Word Developer's Kit disk) to your hard disk and set it up as an ODBC data source to use when running the example macros.