CONNECT TO (E-SQL)

The CONNECT TO statement connects to a specific database with the supplied username and password.

Syntax

CONNECT TO {[server_name.]database_name} [AS connection_name] USER [login[.password] | $integrated]

Arguments
server_name
Is the server running Microsoft® SQL Server™. If you omit server_name, the local server is assumed.
database_name
Is the database.
connection_name
Is a name for the connection. Connection names can have as many as 30 characters and can include alphanumeric characters and any symbols that are legal in file names. Hyphens (-) are not permitted. The first character must be a letter. Do not use current or all for the connection name; they are not supported.
login
Is the user’s login ID.
password
Is the user’s password.
$integrated
Specifies that forced integrated security is used for run-time or compile-time applications instead of the login and password.
Remarks

The options can include character literals or host variables. If you use only one connection, you do not need to supply a name for the connection. When you use more than one connection, you must specify a name for each connection.

Connection names are global within a process. Named connections are shared by separately compiled programs linked into a single executable module. Named connections are also shared by a program and dynamic-link libraries that execute in a single process.

All database transactions after a CONNECT TO statement that do not involve a browse cursor work through the most recently declared, current connection. To use a different connection, you must use the SET CONNECTION statement.

Examples

EXEC SQL CONNECT TO :svr USER :usr;

  

Or

EXEC SQL CONNECT TO "gizmo.pubs" USER "sa";

  

Or

EXEC SQL CONNECT TO gizmo.pubs USER sa;

  

See Also
DISCONNECT  

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.