To read the article online, visit http://www.4GuysFromRolla.com/webtech/070699-1.shtml

A Nifty Way to Create Connection Strings


We've all created DSN-less connection strings. There are basic parts to the connection string. If you are connecting to a SQL database, you need the UID, the PWD, the DATABASE, the DRIVER, the SERVER, and other optional information. If you're connecting to an Access database, you need the DRIVER, and the DBQ, and some other optional information.

There is a drawback to this approach. First, it's prone to human typos. If you mistype the DBQ, you're SOL; if you forgot to add the SERVER name for the SQL DSN-less connection, well, you're SOL. (Of course it's a quick fix, but we shouldn't be succeptible to making these silly errors.) There's a simple, foolproof, incredibly easy way to generate your connection strings.

This tip, pointing out to me by longtime 4Guys visitor Volker S., is as simple as cutting and pasting. If you have ADO installed on your machine all you need to do is the following:

  • Right click on the desktop and choose New
  • Select the Microsoft Data Link option
  • A new icon will be created and you'll be prompted to name it; give it any old name
  • Double click on the newly created icon
  • Set up the connection to your database through this handy wizard (basically select to build you own connection string)
  • Finally, open Notepad, then drag the icon inside nodepad
  • You'll see the connection string generated. Cut and paste this into your ASP page(s)!

It's that easy!! Pretty neat, eh? No more silly typos!

Attention Windows 2000 Users!
If you work on a Windows 2000 box and you've tried to implement the technique for creating connection strings documented in this article, you've likely run into problems. When using Windows 2000 you must use a slightly different approach. To learn more be sure to read: Creating Connection Strings in Windows 2000!

Happy Programming!


Article Information
Article Title: A Nifty Way to Create Connection Strings
Article Author: Scott Mitchell
Published Date: Tuesday, July 06, 1999
Article URL: http://www.4GuysFromRolla.com/webtech/070699-1.shtml


Copyright 2017 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers