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

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 the 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 the ODBC specification 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= prefix and so this tends to work.

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