This article, the second of two parts, looks at the different database applications available for use with ColdFusion. It is excerpted from chapter two of the book ColdFusion Web Development with Dreamweaver MX 2004, written by Jen and Peter de Haan et al. (Apress; ISBN: 1590592379).
Databases and Dreamweaver MX 2004, concluded (Page 1 of 5 )
Setting Up a Data Source
As mentioned before, when you installed ColdFusion, some databases were also installed by default. ColdFusion usually sets up data sources automatically for these databases. However, in case you don’t have a data source set up, we will briefly explain how to use the ColdFusion Administrator to set up data sources for Access databases. The procedure for other databases is similar but may require additional information (such as a database username and password in the case of Microsoft SQL Server and Oracle databases).
Open a web browser and direct it tohttp://localhost:8500/CFIDE/administrator/. If you’ve set up your ColdFusion server on a port other than 8500, you will need to modify this URL accordingly.
Once you’ve logged into the Administrator, click on Data Sources under the Data & Services section of the menu on the left-hand side. If CompanyInfo shows up in the Connected Data Source area with aMicrosoft Access driver, click on it. Otherwise, enter CompanyInfoin the Data Source Name field in the Add New Data Source area near the top of the window. (We will reference this name later in Dreamweaver and in the<cfquery>CFML tag.) Next select Microsoft Access from the Driver drop-down menu, and then click on the Add button. You will now see the dialog box shown in Figure 2-6.
Figure 2-6. The Microsoft Access Data Source dialog box
Next click on the Browse Server button beside the Database File field and navigate to the directory where you installed ColdFusion server (typically,C:\CFusionMX\). From here, navigate into the db folder, selectcompany.mdb, and click on Apply.
You’ll be taken back to the previous screen with the path to the database file filled in. Make sure that Use Default Username is checked, and click on Submit.
The Administrator window will now list all of your data sources, as shown in Figure 2-7.
Figure 2-7. The Data Sources screen, showing CompanyInfo as a connected Data Source
If you have successfully created the data source, then you will see OK in the Status column and “datasource updated successfully” at the top of your screen, as shown in Figure 2-7. Otherwise, you will be presented with error messages.
Now that you have successfully configured your database, let’s create some queries!