Easysoft ODBC-ODBC Bridge

How do I specify connection attributes for my DSN that are not configurable in the odbc.ini?

Article:
00064
Last Reviewed:
8th January 2024
Revision:
2

My ODBC driver requires additional attributes that I have specified in my odbc.ini file, but they do not seem to get through to the driver. The Easysoft ODBC-ODBC Bridge only picks up from the odbc.ini file the attributes specified in the DSN?. If you need to specify additional attributes, you must pass them in the connection string to SQLDriverConnect().

For Perl, see the answer to the question "How can I put attributes other than the DSN in my Perl DBI->connect call?"

For PHP and ODBC-ODBC Bridge, there is a simple trick you can use. Add the attributes to a string passed to odbc_connect() as the DSN name, separating the attributes with semicolons.

E.g. if you were calling odbc_connect with

odbc_connect("mydsn","username", "password")

and wanted to pass the ENG attribute with a value of engine. use:

odbc_connect("mydsn;ENG=engine","username","password")

Calls made by applications to SQLConnect in ODBC-ODBC Bridge are actually redirected to SQLDriverConnect, once "DSN=" is prefixed to the DSN name in SQLConnect's first argument. The disadvantage of this method is that if you are using a Driver Manager (e.g. unixODBC), the string passed must be less than 32 (SQL_MAX_DSN_NAME) characters, so it is rather limiting. (The same does not apply to Perl, as Perl calls, SQLConnect and if that fails, SQLDriverConnect).

For applications that you have the source code for, you will need to edit the code, find the call to SQLDriverConnect and add your attributes to the string argument 3 (InConnectionString). If the application uses SQLConnect instead of SQLDriverConnect (e.g. isql that comes with unixODBC), you will need to change it to use SQLDriverConnect. (See the demo.c program in the ODBC-ODBC Bridge examples directory for code using SQLDriverConnect).

Applies To

Knowledge Base Feedback

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

(* Required Fields)