ODBCConnect
(Engine-Level Function)
Description: | Forms a connection to an ODBC-compliant database and returns the ODBC value associated with that database. |
Returns: | ODBC database |
Usage: | Script Only. |
Function Groups: | Database and Data Source, ODBC |
Related to: | ODBC | ODBCConfigureData | ODBCDisconnect | ODBCSources | ODBCStatus | ODBCTables | TODBC | TODBCConnect | TODBCDisconnect |
Format: | ODBCConnect(DSName, UserName, Password [, ErrorMsg, SQLState, ErrorCode, Disconnect, LoginTimeout, ConnectTimeout]) |
Parameters: |
DSName |
Required. Any text expression for the ODBC data source name, as configured in the ODBC setup menu under Microsoft Windows™. |
UserName |
Required. Any text expression for the ODBC login user name. |
Password |
Required. Any text expression for the ODBC login password. |
ErrorMsg |
A descriptive error or status message, returned by the function. If valid, both ErrorMsg and SQLState will be valid. |
SQLState |
A 5-character SQL State code. SQL State codes are defined by Microsoft and by the vendor of each ODBC driver. |
ErrorCode |
An unsuccessful operation always returns a non-zero value, which is a numeric error code specific to the DBMS vendor's ODBC driver or Microsoft's ODBC Driver Manager. A successful operation will always return a 0. ErrorMsg and SQLState may or may not be set valid in the event of a successful connection. If set valid, they should be examined for relevant status information. |
Disconnect |
An optional parameter that is any logical expression that determines how errors are to be handled. If true (non-0), the connection to the database will be disconnected should any error (no matter how minor) occur. If false (0) an error will not cause a disconnect to occur. The default value is false. |
LoginTimeout |
Optional. An SQLUINTEGER (unsigned long) value corresponding to the number of seconds to wait for a login request to complete before returning to the application. The default is driver-dependent. If the value is 0, then the timeout is disabled and a connection attempt will wait indefinitely. If the specified timeout exceeds the maximum login timeout in the data source, then the driver substitutes that value and returns SQLSTATE 01S02 (Option value changed). |
ConnectTimeout |
Optional. An SQLUINTEGER value corresponding to the number of seconds to wait for any request on the connection to complete before returning to the application. The driver should return SQLSTATE HYT00 (Timeout expired) any time that it is possible to time out in a situation not associated with query execution or login. If the value is equal to 0 (the default) then there is no timeout. |
Comments: |
If the UserName and Password parameters are specified as invalid, the DSName parameter is treated as a literal connection string for the ODBC connection. For example, in the statement ODBCConnect("DSN=MyData;UID=;PWD=", Invalid, Invalid), the first parameter is used to set the attributes of the connection, which makes this statement equivalent to ODBCConnect("MyData", "", ""). |