Easysoft ODBC-ODBC Bridge

Why does Perl DBD::ODBC appear to open the DEFAULT data source with ODBC-ODBC Bridge?

Article:
00097
Last Reviewed:
8th January 2024
Revision:
1

Since DBD::ODBC 0.21, Perl has required an ODBC Driver Manager (or at least some of the functions a Driver Manager supplies). In addition, since 0.21, the DBD::ODBC module connection code (dbdimp.c) started calling SQLDriverConnect first with your DSN name, and, if that fails, calls SQLConnect with the same DSN name. The problem is that SQLDriverConnect is supposed to take a list of attributes of the form:

attribute=name;

and a DSN should be specified as "DSN=name;". Perl DBD::ODBC does not appear to append the "DSN=" to the DSN before calling SQLDriverConnect and so the Easysoft ODBC-ODBC Bridge follows ODBC and assumes a DSN=DEFAULT. If the DEFAULT DSN is not found (likely), DBD::ODBC tries calling SQLConnect with the same DSN name, but SQLConnect only takes a DSN name and does not require the "DSN=" so this tends to work.

If the time taken to go through this process bothers you, change the name on your DBI->connect calls to DBI:ODBC:DSN=dsnname. However, one warning here; the db username and db password (second and third arguments to DBI->connect) are ignored when using SQLDriverConnect, so you need to put UID=dbuser;PWD=dbpass into the connection string, if your database engine requires authentication.

Applies To

Knowledge Base Feedback

* Did this content help you?
* Please select one option based on your first choice:

(* Required Fields)