Connecting to a Database

Once you have created a Database object, you can connect to a database. IDL DataMiner offers two options for accessing databases:

  1. The DIALOG_DBCONNECT function and the ODBC dialog boxes.
  2. The Connect method of the IDL Database Object.

Connecting with the DIALOG_DBCONNECT Function

DIALOG_DBCONNECT is a function used to connect to a database using ODBC dialog boxes. These dialogs prompt you for information required to connect to the desired database.

To connect to a database using the DIALOG_DBCONNECT function, enter the following at the IDL prompt:

status = DIALOG_DBCONNECT(objDB) 

The SQL Data Sources dialog box appears. This dialog box lists the currently defined Data Sources; it looks something like the following figure:

Figure 2-1: SQL Data Sources (Windows dialog)

odbc1.gif

You can take one of three actions:

Note
Due to Motif library inconsistencies, this dialog may fail on some UNIX systems.

Figure 2-2: SQL Data Sources (Motif dialog)

motifodbc.gif

Define a new data source for the system by selecting the desired ODBC driver from the list and clicking the OK button. The dialog box will close and you will be connected to a database. In some cases, you will see an additional configuration dialog after the Add Data Source dialog closes.

Figure 2-3: Add Data Source

AddDataSource.gif

Connecting with the IDL Database Object's Connect Method

To connect to a database using the database object's Connect method, enter the following at the IDL prompt:

objDB->Connect, datasource = source_name 

where source_name is the name of the data source. One way to specify the datasource name is to provide an index into the array of datasource names created with the IDL commands shown in Finding Available Databases, above. For example, if you wanted to connect to the first available datasource in the list of available sources, you might use the following IDL commands:

sources = objDB->GetDatasources() 
mysource = sources[0].datasource 
objDB->Connect, datasource = mysource 

Once you have connected to a database, you can perform several operations using IDL DataMiner methods. These operations include: