Re: Connect to remote MySQL database.
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.
--
Best regards,
Bogdan Degtyariov