To open a connection to the CONNX ODBC Driver

A connection string must be used with a connection object to open a connection to a server. A recordset requires a SQL query string and an open connection object to retrieve a recordset from a server. See CONNX ODBC Connection String Parameters for a complete list of the available CONNX connection parameters.

The ADO technology available in Microsoft Visual Basic can be used to open connections within CONNX. Use the following instructions to activate ADO in Visual Basic:

  1. Select Project on the File menu.

  2. Select the check boxes for Microsoft ActiveX Data Objects Library and Microsoft ActiveX Data Objects Recordset Library, and then click the OK button.

  3. Enter the following code snippet:

Public Sub ConnectToDb()

Dim con as new ADODB.Connection

Dim rec as new ADODB.Recordset

Dim strConnection as string

Dim strSQLQuery as string

 

strConnection = "DSN=MYDSN;UID=MYUSER;PWD=MYPASSWORD"

strSQLQuery = "SELECT * FROM MYTABLE"

 

 

con.Open strConnection

rec.Open strSQLQuery, con

End Sub

where MYDSN is a DSN created on your computer, MYUSER and MYPASSWORD are valid CONNX user names and passwords. MYTABLE is any table located in a CONNX Data Dictionary (CDD).