The SQLDriverConnect connection string uses the following keywords.
Keyword | Description |
---|---|
DSN | The name of the data source as it is returned by SQLDataSources. The DSN keyword is not used if the DRIVER keyword is used. |
DRIVER | The name of the driver as returned by SQLDrivers. The DRIVER keyword is not used if the DSN keyword is used. The SQL Server driver name is {SQL Server}. (For a 16-bit program, the 32-bit driver name is {SQL Server (32 bit)}.) |
SERVER | The name of the server on the network on which the data source resides. When running on Microsoft Windows NT, "(local)" can be entered as the server, in which case, a local copy of SQL Server can be used, even when this is a non-networked version. Note that when the 16-bit SQL Server driver is using "(local)" without a network, the "MS Loopback Adapter" must be installed. |
UID | The user login ID. |
PWD | The user-specified password. |
APP | The name of the application calling SQLDriverConnect (optional). |
WSID | The workstation ID. Typically, this is the network name of the computer on which the application resides (optional). |
DATABASE | The name of the SQL Server database (optional). |
LANGUAGE | The national language to be used by SQL Server (optional). |
SQLDriverConnect uses keyword values from the dialog box (if one is displayed). If a keyword value is not set in the dialog box, SQLDriverConnect uses the value from the connection string. If the value is not set in the connection string, it uses the value from the ODBC.INI file.
If the fDriverCompletion argument is SQL_DRIVER_NOPROMPT or SQL_DRIVER_COMPLETE_REQUIRED, the language or database comes from the connection string, and if the language or database is invalid, SQLDriverConnect returns SQL_ERROR.
If the fDriverCompletion argument is SQL_DRIVER_NOPROMPT or SQL_DRIVER_COMPLETE_REQUIRED, the language or database comes from the ODBC data source definitions, and if the language or database is invalid, SQLDriverConnect uses the default language or database for the specified user ID and returns SQL_SUCCESS_WITH_INFO.
If the fDriverCompletion argument is SQL_DRIVER_COMPLETE or SQL_DRIVER_PROMPT and if the language or database is invalid, SQLDriverConnect redisplays the dialog box.
For example, to connect to the Human Resources data source on the server HRSERVER using the login ID Smith and the password Sesame, you would use the following connection string:
DSN=Human Resources;UID=Smith;PWD=Sesame
To specify the Payroll database on the same server, you would use the following connection string:
DSN=Human Resources;UID=Smith;PWD=Sesame;DATABASE=Payroll
To specify the SQL Server driver (the driver name is {SQL Server}) and server name directly (without using a DSN), you would use the following connection string:
DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame;
DATABASE=Payroll