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:
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:
The SQL Data Sources dialog box appears. This dialog box lists the currently defined Data Sources; it looks something like the following figure:
You can take one of three actions:
Note
Due to Motif library inconsistencies, this dialog may fail on some UNIX systems.
- Select the desired data source and click "OK". After selecting this button, a "true" value is returned if the database object connects to the data source.
- Cancel the operation by clicking "Cancel". After selecting this button, a "false" value is returned, and the database object does not connect to the data source.
- On Windows systems, click "New" to define a new data source for the system. After selecting this button, the Add Data Source dialog box appears. This button is not available on Motif systems.
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.
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:
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:
- finding out which tables are available in the datasource;
- finding specific tables in the datasource;
- executing SQL statements to perform actions such as creating a table or deleting a table;
- getting database properties;
- creating a recordset and connecting to tables; and
- retrieving and manipulating table data.


