When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Tuesday, July 06, 1999

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.

- continued -

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!

ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article