This is an old revision of the document!
Table of Contents
How to connect to a database using ODBC driver and not using DSN
Intro
ODBC is still a great tool for connect to a database. However, in some environments it's difficult to
create a DSN to configure the acess to the database. Or even worse, it's cumbersome to have a configuration
file with the DSN name and the DSN itself configured in the ODBC administrator and –maybe– a tnsnames.ora
file with more configuration details of the database.
So, a way to override the use of a DSN and configure it directly in our program is convenient. In this page I will explain how to achieve that.
Step 1: create a ''test.udl'' for the test
We will start by creating an udl file. For the purpose of this tutorial, I will call mine test.udl
.
You can create such a file by the means of creating an empty text file (test.txt
) and renaming
it to test.udl
. Open it with double click and you will have something like this:
Step 2: open it and pick an OLE DB provider
Move to the “provider” tab and make sure you select the proper driver, that should be “Microsoft OLE DB Provider for ODBC Drivers”:
Step 3: move back to "connection" and create a new connection string
Moving back to the Connection tab, you have to click on “Use connection string”.