From the April 2009 Issue of Prestwood eMag
Design Windows Hosting:
Using a Database DSN
Posted 3/19/2003 on 3/19/2003
Take Away: How to use a DSN to connect to a database (specific to our Windows web hosting clients).


A Data Source Name, or DSN, is how you reference your database in your ASP applications.  The DSN describes important information about your database, including the path where it resides as well as the ODBC driver that should be used to access it.  

Creating a System Data Source Name for a database is an easy task with the ODBC Control Panel.  It is accessible through the "Database Tools" link in the Control Panel.

Adding a DSN

The following information is needed to successfully create a System DSN for your database:

  • DSN Name
  • Database Name
  • Database Type

You should set the DSN name to something that will reflect which particular database you are configuring the DSN for.  Please note that you will need to refer to your DSN in the format userid.[DSN Name] in your applications (where userid is your account's User ID).  The database name is the path to the database on your site for Microsoft Access and Microsoft FoxPro databases.  For Microsoft SQL Server databases, enter your username as the database name.  You will also need to specify what type of database you are using: Microsoft Access, Microsoft FoxPro, or SQL Server.

The first thing you will see in the Database Tools control panel is the ODBC Data Sources list.  From here you can see information about the System DSNs that have already been created and add new System DSNs.  To create a new DSN, click on the "Add New Data Source" button.

Now you will see the Data Sources form.  This where you can enter all the information required to configure your DSN.  If you wanted to create a DSN called "myDB" for an Access database called "my.mdb" residing in the "data" directory of your site, you would fill out the form as illustrated below.

ODBC Data Sources
Status: Ready for a new record
DSN Name
Database Name

Clicking on the "Insert" button will add the DSN to the server and you will be taken to the "Feedback" form.  Here you can review the the configuration for the DSN you just set up.  You will also have the option of creating another new DSN or going back to the ODBC Data Sources List.

Modifying or Deleting a DSN

If you have already created a DSN, you will have the option of changing the database name or deleting the DSN altogether.  From the ODBC Data Sources list, you can select an individual DSN by clicking on it's number.

ODBC Data Sources
current Filter
Num UserID DSN Name Database Name Header Type
    myuser myDB data\my.mdb Access

Now you will be able to change the name of the database in the in the textbox.   The change will be made on the server upon clicking the "Update" button.   You can also delete the DSN by clicking the "Delete" button.


  • Remember that you must reference your DSN as userid.[DSN Name].
  • Your database must be stored in the "data" directory of the site if you want to allow write access in your web applications.  By default, in order to protect your databases, the /data directory is configured to deny all web requests.
KB Post Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile For service: 916-726-5675
Copyright (C) Prestwood IT Solutions.
All Rights Reserved.
Printed 9/27/2020