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:

https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-configuration-connection-parameters.html

More information about usage of SQLDriverConnect():
https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqldriverconnect-function

Thanks.

Options: ReplyQuote


Subject
Written By
Posted
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.