• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 29. Building a Basic ColdFusion Site > Setting Up a Database Connection

Setting Up a Database Connection

In ColdFusion terms, the database connection is a script that calls on the driver to talk to the database. Dreamweaver creates this script for you and stores it in a special connections file when you choose data source name (DSN) from the Databases panel. Because this information gets stored in a special file that can be accessed by any page in your site, you have to define the connection only once for the entire site.

Exercise 29.2 Creating a Database Connection

In this exercise, you create the connection script that will allow your pages to communicate with the antiques database. You must already have installed your database and created a driver for it (as outlined in the preceding section) before continuing with this exercise.

Because Dreamweaver has to know what kind of connection to create, you must have a dynamic document open before you can create the connection. From your local site, open catalog.cfm.

From the Application panel group, open the Databases panel. The panel will display help information letting you know what needs to happen before you can set up your connection. If you have catalog.cfm open, the display will indicate that your next step is to establish your RDS login to the ColdFusion Server (see Figure 29.6).

Figure 29.6. The Databases panel ready to log on to the ColdFusion Server.

Click the RDS login link and the Login dialog box appears. Enter the password you established when you installed ColdFusion Server and click OK.

As soon as you click OK, Dreamweaver connects to the server and collects a list of available data sources. The AntiquesBarn driver you defined earlier will appear in this list, along with several other drivers (see Figure 29.7).

Figure 29.7. The Databases panel showing all databases available to the ColdFusion Server.

That’s it! You’re done. Congratulations! You can now use this panel to explore your database. Expand the AntiquesBarn connection icon to see Tables, Views, and Stored Procedures. The antiques database contains only tables. Expand the Tables icon all the way to see that the database contains two tables—stockitems and customers—and to see what columns (information fields) each table contains. You cannot see the records stored in the database from here, but you can examine its structure (see Figure 29.8).

Figure 29.8. The Databases panel showing the structure of the antiques database.


What happened here? If you’re used to working with ASP or other server technologies, you might be wondering where Dreamweaver has put your connection information. When working with ColdFusion, there is no need for specific connection scripts stored inside your site, because the ColdFusion Server keeps track of all this information. As long as you’re logged in to the server, all DSNs that the server can see are available to you.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint