There can be many reasons for getting SQL_ERROR
back from SQLDriverConnect or SQLConnect. Refer to How do I find out why an ODBC call is failing first. The most likely reasons are:
odbc.ini
or ODBC Data Source Administrator. The Driver Manager couldn't find the data source. The TargetDSN
attribute was missing from the data source or connection string. Refer also to HY000
below.
The most common reason for this when connecting to Windows is setting TargetDSN
to specify a user DSN instead of a system DSN. Check that the ODBC data source on your Windows machine is a system DSN.
LogonUser
and LogonAuth
attribute pair or the TargetUser
and TargetAuth
attribute pair have invalid values. LogonUser
and LogonAuth
must specify a user name and password that the ODBC-ODBC Bridge server can use to log on to the target machine. The ODBC-ODBC Bridge passes TargetUser
and TargetAuth
to the remote SQLDriverConnect call. The target ODBC driver uses these credentials for database authentication (if required).Server
can't be found, is not running the ODBC-ODBC Bridge server, or is affected by a networking issue. Check that the Server
attribute value is a valid machine name or IP address. Check the machine name is resolvable by DNS or is present in the hosts
file. Check that you are on the same network by pinging the target server. Check the Port
attribute in the specified data source is correct. Try telnetting to the server machine on that port.SERVER
attribute from the data source, you get an IM002
error and then a secondary HY000
error explaining what the problem is.