Before you can build pages that are database driven, you must first establish a connection between your Web server and your database. In the Windows operating system, this process is relatively straightforward, but there are several potential pitfalls that can keep your pages from effectively communicating with your database. This article shows you the step-by-step process of setting up a data source name for your database.

This article was excerpted from Inside Dreamweaver UltraDev, by Sean Nicholson.

Creating a Data Source Name (DSN) Entry
After you have built your database and have it located on your Web server, the first step in building your database-driven site is to create an avenue of communication between your Web server and the database. While this can be accomplished using drivers designed specifically for your flavor of database, it is much easier to use the Open Database Connectivity Driver (ODBC) or the Java Database Connectivity Driver (JDBC) to accomplish the task.

ODBC and JDBC are standards that have been developed for communicating with modern databases. Most of today’s databases, including Access, SQL Server, and DB2, are capable of using the ODBC driver. Other databases are capable of using the JDBC driver. For instance, MySQL can either use the standard JDBC driver or connect through the ODBC driver using an additional program called MyODBC.

How Many Drivers Do You Need?
An ODBC or JDBC driver must be set up for each database that you want to connect to the Web.UltraDev also requires that you have the most recent ODBC drivers available in order to function properly. If you have not already installed the latest Microsoft Data Access Components (MDAC), I highly recommend that you take a moment and download them from MDAC and install them on your workstation.

Article Exercise: Establishing an ODBC Data Source for Your Database
Setting up an ODBC data source on your workstation differs among operating systems. If the machine that you set up as your Web server is a Windows 9x machine, click Start/Settings/Control Panel. In the Control Panel, select ODBC Data Sources (32bit). If you are using Windows NT, select Start/Settings/Control Panel and select the Data Sources (ODBC) icon. If, however, your machine is using Windows 2000, you should select Start/Settings/Control Panel and choose the Administrative Tools icon. Within the Administrative Tools window, choose the Data Sources (ODBC) icon.

setting up a ODBC data source

Choose the System DSN tab from the ODBC Data Source Administrator dialog box, shown in , and click the Add button.The System DSN tab allows you to create a data source that can be shared on the Internet. Using a System DSN

Caution: To make a database available to your Web page visitors, you must create the ODBC source under the System DSN tab.

ODBC Microsoft Access Setup

Select the Microsoft Access driver and click Finish.In the ODBC Microsoft Access Setup dialog box, shown below, type the name you wish to use for your data source name in the Data Source Name field.In the Database panel of the ODBC Microsoft Access Setup dialog box, click the Select button.

Navigate to the location of your database on your Web server and click OK

Click the Options>> button located in the lower-right corner of the ODBC Microsoft Access Setup dialog box. In the Page Timeout field, type 5000.

Changing the Default Page Timeout

Caution: It is especially important that you change the default page timeout setting if you are using Windows 2000 as your Web server and an Access database. Failing to change this value can result in permission problems when accessing database-driven Web pages. For more information on this potential problem, visit Microsoft.

Click OK to close the ODBC Microsoft Access Setup dialog box.

As shown in the screenshot below the ODBC Data Source Administrator dialog box now shows a data source for your database.

ODBC Microsoft Access Setup

A data source has been created for your database.

The ODBC Microsoft Access Setup box.
Before you can build pages that are database driven, you must first establish a connection between your Web server and your database. In the Windows operating system, this process is relatively straightforward, but there are several potential pitfalls that can keep your pages from effectively communicating with your database. This article shows you the step-by-step process of setting up a data source name for your database.

Any suggestions, ideas? Feel free to comment on this article!
Back to Top

Advertisements