[unixODBC-support] SQLConnect and odbc.ini

Nick Gorham nick.gorham at easysoft.com
Mon May 2 21:34:40 BST 2005

Thinh Nguyen wrote:

> Hi,
> I have to connect to mySQL server via unixODBC, and SQLConnect() 
> doesn't seem to honor the parameters set in odbc.ini.
> I'm wondering:
> -- why does odbc always connects to the MySQL server run on the 
> default port on localhost.
> -- why does it always use the database named "MySQL". Should the DSN 
> name always be the name of the database we try to use then?
> -- the only param it seems to care is the "Driver". How do I make it 
> honor the other params as well? (To get around the problem, I have 
> been using SQLDriverConnect() instead so I can pass the hostname and 
> port I wanted to connect to)
> Thanks a lot in advance for any help.

All of those are down to the driver to read from the ini file. I would 
check the driver you hae is built to use unixODBC's libodbcinst.so so it 
reads the same ini file as unixODBC

> Thinh
> This is odbc.ini content:
> [ODBC Data Sources]
> MySQL = MySQL ODBC 3.51 Driver DSN

You don't need that part in a unixODBC ini file, but it doesn't do any harm.

> [MySQL]
> Driver       = /dbs/tpp/odbchome/drivers/lib/libmyodbc3.so
> Description  = MySQL ODBC 3.51 Driver DSN
> Server       = quality.iii.com
> Port         =  1032
> user         =  testapp
> Password     = testapp
> Database     = test
> Option       = 4

More information about the unixODBC-support mailing list