In order to connect to a database using an ADO object, you need a connection string. Here’s a simple way to get one in Windows, and all you need to do it is… your desktop.

New Text File
First, right-click on your desktop and create a new text file. It doesn’t matter what you name it, I usually keep mine as “New Text File”

 

UDL File
Next, rename your new file with a .UDL extension. Notice that when you do, the icon changes to something that ISN’T a text file.

 



Double-click on your UDL file.

The configuration wizard for a database connection appears:
ADO Connection Wizard1
Configure your connection! The FIRST thing you’ll want to do is click on the “Provider” tab and select the type of your data source…. SQL, Oracle, Access… whatever. If the type you’re looking for doesn’t appear in this list, then your computer can’t connect to that kind of database until you install appropriate drivers.

After you’ve selected your provider, click on the “Connection” tab.
ADO Connection Wizard2
Select the database server.
Enter the username/password or select “Use Windows NT Authenticated Security,” depending on your needs.
Select database

If the first two things are done correctly, then when you click on the dropdown list next to “select database on server”, you should see a list of databases for you to pick from. If you do NOT see a list of databases or get an error message, then you need to re-check the server and username/password. Check to make sure the servername is correct, that it is reachable over the network (ping it!), and that the username you provided has access to it. If you are using windows authentication, make sure the database is set up for that, and that the ID that you are logged onto the computer with has access to the database.

Click on “Text the Connection” to make sure you’ve done everything right.

If it tests okay, close the wizard.

Rename your .UDL file BACK to a text file and open it with a text editor. Your connection string will be there. Copy and paste to your code editor of choice.

Popularity: 10% [?]

  • No Related Posts Found
  • Leave a Reply