10. Understanding ODBC Connectivity : ODBC Programming : ODBC User Authentication : User Name and Password
 
Share this page                  
User Name and Password
SQLConnect() and SQLDriverConnect() allow your application to specify a user (login) name and password. For example:
SQLConnect(hdbc,                /* Connection handle */
       (SQLCHAR *)"myDSN",      /* The ODBC DSN definition */
        SQL_NTS,                /* This is a null-terminated string */
       (SQLCHAR *)"myUserName", /* Local user name */
        SQL_NTS,                /* This is a null-terminated string */
       (SQLCHAR *)"myPassword,  /* Local password */
        SQL_NTS);               /* This is a null-terminated string */
In SQLDriverConnect(), the "uid" and "pwd" attributes specify the local user name and local password, respectively.
Specification of the user name and password authorizes the ODBC application to act as it were logged in to the local machine as that user. This is true even if the ODBC DSN definition specifies a network connection to another machine. If you specify an invalid user name or password, the connection fails regardless of whether the connection target is local or over the network.