Data Source Name (DSN) - Page 6
July 29,2002
While a custom connection string is a faster connection,
it requires us to know some detailed information about the database we are
connecting to such as the physical path of the database on the server – this
is not always readily available. The next best thing would be to simply create
a DSN, which is basically a pointer to a System Data Source you set up in
the ODBC manager on the server. Once you set one up on the server, you only
need to know the DSN name and the username/password (if any) in order to create
the connection. The connection string simply becomes DSN=dsn_name. Dreamweaver MX will generate this string for you as it does custom connection
strings.
As you will see, the DSN must be created on the server that
actually holds the database. You can create one on your own machine if you
are hosting your own site and have access to the Data Sources administration.
But if your site is being hosted remotely by a hosting company with which
you don't have access to administration you can tell your web host to create
the DSN(s) for you if it comes with your web hosting package. However some
hosting companies give their users the ability to create their own DSNs through
some sort of virtual control panel.
In any case, following these instructions creates a DSN:
·
Open your Data Sources (ODBC) administrator from your
Control Panel (see earlier in the chapter for
a description of exactly where this is)
·
Click the System DSN tab
·
Click the Add... tab to add a new DSN
·
The Create
New Data Source dialog box will now appear, listing all the drivers
currently loaded on the system. Select the driver appropriate to your database,
for example Microsoft Access Database (*.mdb)
for Access, and then click Finish
·
In the final dialog box that now appears, first enter a Data Source Name and Description for the
DSN (I chose Webprodmx for my DSN
name). Second, click the Select...
button and navigate to your chosen database. Click OK, and the new DSN should be added to your
System DSN list; it should now be available
for use in Dreamweaver MX
Now let's go back into Dreamweaver MX and create a connection
using our DSN. Select the Databases tab and click the plus sign (+). Select the Data Source Name (DSN) option and the following
dialog box will pop up.
Fill in a name for your connection and select your DSN from
the list. If your database is protected with a username and password enter
them in the fields; if not, leave them empty (we didn't have to do this when
we were using a custom connection string because this information is already
provided by the string). Again, it is advised that you test the connection
– if it is successful hit OK, and OK
out of the Data Source Name (DSN)
pop-up.
The connection will then be added to the connections list
underneath the Databases tab. You
can create connections to different databases for the same site, but one usually
suffices since all your data will most likely be stored in one database. Creating
a connection to your database is the first thing you need to do when preparing
a database-driven web application – until then, none of the other ASP application
behaviors will be made available.
Password-Protected Access Database - Page 5
Dynamic Dreamweaver MX
Bindings Page 7
|