To use database information in our web pages, we must first create a connection to our database and specify a DSN. This is done using ColdFusion Administrator.
ColdFusion Administrator is a browser-based tool for configuring your ColdFusion Server. To access ColdFusion Administrator, either choose Start, Programs, Macromedia ColdFusion MX Server, ColdFusion Administrator or enter http://localhost/CFIDE/administrator/ into your browser. When presented with the login screen, enter the password you specified during installation (see Figure 1).
Figure 1 The ColdFusion Administrator login.
After you have logged in, select Data Sources (the first item under Data & Services) from the navigation menu on the left (see Figure 2). This is where you create new database connections and check the status of existing connections. Select the down arrow with the Driver drop-down menu to view all the different types. To add a connection to a database named Staff.mdb, type Staff in the Data Source Name box and choose Microsoft Access from the Driver drop-down menu. After you have entered the proper settings, click the Add button.
Figure 2 The ColdFusion Administrator Data Sources display.
Now that we have specified the DSN and the appropriate driver, we need to tell ColdFusion where to find our database file. In the Macromedia Microsoft Access Data Source: Staff window, enter the path information for your Staff.mdb file or use the Browse Server button to browse to its location. The Staff.mdb files should be located in your web server folder (see Figure 3). After you have entered all the appropriate information, click the Submit button. Be sure to tick the Use Default Username check box even if the database has no username security in place.
Figure 3 Database configuration.
The database file can be located anywhere in your directory structure; it does not have to be in the web server's root folder. As a matter of fact, it is a good idea to keep it outside of your web root folder for security reasons.
After the database connection has been set, you should get an OK indication in the Status column next to your new data source. You can use the Verify All Connections button to check the status of existing connections (see Figure 4).
Figure 4 Data source status display.
After the connection has been set, you can begin to use that connection in your web pages. You should only need to go back into ColdFusion Administrator if you change the filename or location of your database.
If you are using a commercial service provider for your hosting, you might have to request that they set up the data source for you. Some hosting providers do not provide an administration interface into ColdFusion Administrator. Normally, you would provide your hosting company with the DSN you want to use, the name of the database file, and its location within your web site file structure.