I.T. Discussion Community!
-Collapse +Expand
Design
Search Design Group:

Advanced
-Collapse +Expand Design Store
PRESTWOODSTORE

Prestwood eMagazine

April Edition
Subscribe now! It's Free!
Enter your email:

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

KB100170



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
Type

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.

Notes

  • 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.

Comments

0 Comments.
Share a thought or comment...
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1207A1
Enter key:
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 play-drums.com 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

 KB Article #100170 Counter
5270
Since 4/2/2008
-
   Contact Us!
 
PrestwoodBoards.com was developed and is maintainted by me. Do you have a question or suggestion? Do you see a problem? Contact me now. My goal is to build an ad-free and spam-free source of I.T. information with many contributers (ok to promote your website/company in your bio). Yes, my company Prestwood IT Solutions is mentioned in my bio which shows with every post, but you can contribute and promote your pet project too!

3,044 People Online Now!!  
Sign In to see who's online now!  Not a member? Join now. It's free!
Show more stats...


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech