Q_CONNECT

This command establishes a connection to the data source you specify.

Syntax

The "Read-only" setting only works if the ODBC driver supports a Read-only connection.

Q_CONNECT connection_number, "connection_string", "use_GainSeeker_ODBC_driver", "read-only_connection"

connection_number

This parameter must be a number from 1 to 10.

A template may have up to 10 distinct connections to external data sources. A separate data buffer is maintained for each connection.

If you specify a connection_number that already has an active connection to a data source, that previous connection will automatically be disconnected and any queries on that previous connection will be ended.

connection_string

This parameter specifies the name of the data source and any connection information needed to connect to it. There are three basic options for setting this parameter:

For many data sources, you must specify a login name and password (or encrypted password) for the database.

use_GainSeeker_ODBC_driver

read-only_connection

Return value

If the connection to the data source is successful, this command returns the number 1.

Otherwise, it returns the number 0. To understand why the connection was not successful, use Q_ERROR and Q_ERRORDESC.

Notes

The template automatically adds "dsn=" to the beginning of the connection_string parameter.

For a sample template that connects to a data source and then queries the data source, see Database Query Commands.

Examples

Q_CONNECT 1, "GainSeeker71_B", "Y", "N"

This formula uses data source connection number 1 to establish a connection to the "GainSeeker71_B" data source. It also specifies that the "GainSeeker71_B" data source is a GainSeeker ODBC driver and that this is not a read-only connection.

Q_CONNECT 2, "<default>", "Y", "Y"

This formula uses data source connection number 2 to establish a connection to the GainSeeker database. It also specifies that the GainSeeker database is a GainSeeker ODBC driver and that this is a read-only connection.

Q_CONNECT 3, "Production_db;uid=Prod;pwde=NsDf", "N", "Y"

This formula uses data source connection number 3 to establish a connection to the "Production_db" data source with user name "Prod" and encrypted password "NsDf". It also specifies that the "Production_db" data source is not a GainSeeker ODBC driver and that this is a read-only connection.