Connecting to an external database

Create a new ODBCConnection object with "Dim New" or "Set = New." Once the object exists, you can get:

Connect to an external data source with the ConnectTo method of the ODBCConnection object. The external source must be defined in the ODBC Driver Manager at the operating system level. You can test the connection with the IsConnected method.

If the data source requires a user name and a password, you can supply these as arguments to ConnectTo or let the data source prompt the user. You can suppress prompts from the data source by setting the SilentMode property to True, although intermediate software may still prompt.

After you connect to a data source, you can query and update the external tables with the ODBCQuery and ODBCResultSet objects, and can get the following information:

When you are done using a data source to which you connected, disconnect from it with the Disconnect method.