MySQL Forums
Forum List  »  Connector/ODBC

Re: Connect to remote MySQL database.
Posted by: Bogdan Degtyariov
Date: February 05, 2017 07:25PM

Hi Bob,

You do not necessary need a DSN for connecting to MySQL server using MySQL ODBC Driver. The Data Source Name (DSN) is resolved by the ODBC Driver Manager into the set of connection options and credentials specified when the DSN was created.
Thus, the ODBC API function used with DSN connections is SQLConnect().
For instance:

SQLConnect(hdbc, "my_DSN", SQL_NTS, "my_user", SQL_NTS, "my_password", SQL_NTS);

However, the connection options could be specified directly through the connection string given to SQLDriverConnect() function:

SQLDriverConnect(hdbc, NULL, "DRIVER={MySQL ODBC 5.3 Unicode Driver};SERVER=server_host_ddress;USER=my_user;PASSWORD=my_password;DATABASE=my_db", SQL_NTS, ....);

The complete list of all connection parameters that can be specified in the connection string can be found here:

More information about usage of SQLDriverConnect():


Options: ReplyQuote

Written By
Re: Connect to remote MySQL database.
February 05, 2017 07:25PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.