Version: 7.0.0

SQLConnect ​

Function ​

Establishes a connection between the driver and the database.

Prototype ​

c
SQLRETURN  SQLConnect(SQLHDBC        ConnectionHandle,
                      SQLCHAR        *ServerName,
                      SQLSMALLINT    NameLength1,
                      SQLCHAR        *UserName,
                      SQLSMALLINT    NameLength2,
                      SQLCHAR        *Authentication,
                      SQLSMALLINT    NameLength3);

Parameters ​

Table 1 SQLConnect parameters

Keyword

Parameter Description

ConnectionHandle

Connection handle, obtained through SQLAllocHandle.

ServerName

Name of the data source to connect to.

NameLength1

Length of ServerName.

UserName

Database user name in the data source.

NameLength2

Length of UserName.

Authentication

Password of the database user in the data source.

NameLength3

Length of Authentication.

Return Values ​

  • SQL_SUCCESS: The call is successful.

  • SQL_SUCCESS_WITH_INFO: Some warning information is present.

  • SQL_ERROR:The connection failed to be established.

  • SQL_INVALID_HANDLE: The input handle is invalid.

Example ​

See: Example