Understanding Data Source Names
As mentioned earlier, a DSN is used to help a server running ColdFusion, ASP, or the like to connect to a data source. Specifically, a DSN specifies a driver (which enables ColdFusion to communicate with the specific data source you're using, such as a Microsoft Access or SQL Server database) and a path (which tells ColdFusion where to find the data source).Individual pages can interact differently with the data source (in this project, a Microsoft Access database for Windows and a Pointbase database for Macintosh). One page might insert new records into the database. Another page might retrieve and display information from the database. Yet another might retrieve information and enable the user to edit or delete that information. Because each page potentially uses the database in a different way, specific directions for interacting with the database occur on each page.What doesn't change from one page to the next is the relationship to the databasethat is, the path pointing to the database and the driver used to communicate with it. In other words, the DSN is static across pages, even though what two given pages might do with a database can differ. (It's possible to have more than one DSN used in a site, but the information within each DSN doesn't change between pages.)To connect to a data source from any page in the site, you simply specify the DSN (the details of doing so are covered later). When you specify the DSN, you don't have to specify the driver and the path on every page. But it also has another benefit: if the driver ever changes (for example, if you migrate your database from Access to SQL Server) or the path ever changes (say, you upload your site from your hard drive to your ISP, which uses a different setup), all you need to change are the particulars of the DSN itself. All your pages will still work without modification, because they point just to the DSN by name. The figure below illustrates the process of submitting information to a database.[View full size image]

1. | Using Windows Explorer or Macintosh Finder, browse to the Lesson14/Start folder on the CD-ROM. |
The database file used from this point forward is located on the CD that comes with this book.
2. | Windows users: copy dante.mdb. Macintosh users: copy dante.dbn. Access an appropriate folder on the server (see below), and paste the file into that folder. |
For users developing with the built-in ColdFusion Server, the best place to store the database is in the db folder, outside the ColdFusion wwwroot folder. For Windows users with a default ColdFusion install, that is C:\CFusionMX7\db. For Macintosh users with a default ColdFusion install, that is /Applications/ColdFusionMX7/db. All the documents in this folder have the appropriate permissions set.If you're a Windows or Macintosh developer who uses a remote server, the server administrator will tell you where to put the database file. In most cases, it will be separate from the main site for security reasons.