Connecting to a Database

For every Database you want to access in an Opus Pro publication, you must create a database connection. To make the connection, Opus Pro uses ODBC drivers, which allow you to exchange information to and from the database and Opus – without the ODBC driver you cannot communicate between Opus and the database.

Note:
To connect to a database, the ODBC drivers must be installed on your development machine. The links below show you how you can check if ODBC drivers are installed on your machine.

Viewing ODBC drivers installed for Windows 95, 98 and NT

Viewing ODBC drivers installed for Windows 2000

There are a variety of ODBC drivers – one for each type of database system. For example, there are individual ODBC drivers for many database programs, such as: Access, FoxPro, Paradox, dbase, Oracle, and so on. However, the function of each ODBC driver is the same. ODBC drivers translate the data from your database in a meaningful way so that another program, such as Opus Pro, understands what information it is receiving. Therefore, each database you intend to use in Opus Pro is given a Data Source Name (DSN).

The DSN:

1. The DSN is simply a combination of the database you want to open in Opus Pro and the appropriate ODBC driver that will be used to interpret the data for Opus Pro.

Note:
You must create a DSN for each database you want to use, for example, if you want to use two MS Access databases in a publication you must create two DSN’s – one for each database. Each DSN will be made up of the Access ODBC driver and the name of the database – see Create a new DSN below for more information.

2. The DSN is used by the Database Query action to make the connection to the database.

3. When it is time to publish your publication, you do NOT need to send the DSN file with the publication. Opus Pro will automatically store the DSN information internally.

To create a DSN for an MS Access database:

1. Select the object on the page (or the page itself) that will open the database. This is most commonly a button, an image or a page.

2. Double-right click on the object to open its Actions dialog.

3. Select the trigger that will open the database.

Note:
For an object on a page this is most commonly a Left Mouse Click trigger and for a page an On Show trigger.

4. Select the Database menu from the Actions tab.

5. Add the Database Query action to your trigger, as described in adding actions. The Database Query tab will automatically appear when you add the action.

6. Click on the Select… button to create a new DSN – this will open the Select Data Source dialog box.

Note:
Once you have created a DSN on your machine, you can select it from the Select Data Source dialog box. However, if you have not created a DSN for your database already, you will have to create it before you can proceed with this action – see point 7 below.

7. Click the New… button in the File Data Source tab in the Select Data Source dialog to start the Create New Data Source wizard.

8. Select the ODBC driver named Microsoft Access Driver (*.mdb) from the list, then click on the Next button to continue.

Note:
If you are using a database built in a different application, such as, Oracle or dbase, you must select the ODBC driver in the list that matches your database application.

9. Type a descriptive name for this database connection in the box provided, then click on the Next button to continue. The name entered here is the DSN that is used by the Database Query action.

Note:
For example, if the database were a catalogue of your products, a descriptive name for the DSN would be Catalogue.

10. Click on the Finish button to close the Create New Data Source wizard – this will open the ODBC Microsoft Access Setup dialog box.

Note:
Now your DSN has a name and the type of ODBC driver that is going to be used. The final stage is to specify the Data Source, that is, the database you want to use with this DSN.

11. Click the Select… button in the ODBC Microsoft Access Setup dialog to open the Select Database dialog box.

12. In the Select Database dialog navigate to the folder containing the database you want to use as the Data Source, then click on the OK button to save your changes – this will close the dialog and return to the ODBC Microsoft Access Setup dialog.

13. Click the OK button in the ODBC Microsoft Access Setup dialog to save your changes – this will close the dialog and return to the Select Data Source dialog with your new DSN connection in the list.

Note:
You new DSN is now made up of a name (e.g. Catalogue.dsn) and the ODBC driver and database connected to this DSN.

14. Make sure your new DSN connection is in the DSN Name box of the Select Data Source dialog, then click the OK button – this dialog will close and you will be returned to the Database Query action.

Note:
Once you have created a DSN (points 7 to 14 above), for a database on your system, it is permanent – see Re-using DSN’s below for more information.

15. You have created a new DSN and added it to your Database Query action, however, there are other settings you have to make in the action – see Database Query action for more information.

Re-using DSN’s:

1. Once you have created a new DSN connection for a database on your system, it is permanent.

2. You can re-use the same DSN in other Opus Pro publications or in the same publication on other pages.

3. When you want to open the database in a new publication, choose the DSN from the list in the Database Query action.

Related Topics:

the Database Query action

Working with Databases - Overview

Introducing the Database Actions