
The recommended way to connect to your MS Access databases (*.mdb files)
from your web pages is to use a DSN-less connection.
Using a DSN-less connection allows you to setup your own database
connections without requiring the server administrator to create a DSN
for your database on the server.
This document describes how to use DSN-less connections
on the IIS/Windows 2000 server operated by the Department of Computing.
Note: If you want your web-pages to be able to update your database,
you will need to set the access permissions for your .mdb file to allow this.
To do this, connect to igor using SSH Secure Shell Client (or similar),
change to the folder containing your .mdb file and use the 'chmod'
command, like this:
chmod 666 mydb.mdb
replacing mydb.mdb with the name of your .mdb file.
ASP Web Pages
To open a connection to an MS Access database from an ASP web page,
you need to specify the driver and the path to your .mdb file in
the connection string. For example, to connect to a database called
my_db.mdb, you could use the following connection string:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath("my_db.mdb")
There are other formats that can be used for DSN-less ASP connection strings
which will work just as well as the one described above, but this format
is the recommended one and it should work well for most purposes.
Coldfusion Web Pages
To query an MS Access database from a Coldfusion web page,
you need to include an 'IN ...' clause in your SQL query
which specifies the full path to your *.mdb file on the server.
For example, to select the values from the name column
of a table called people
in an MS Access database called my_db.mdb
in the home directory (G: drive) of user ma123az,
you might use a Coldfusion CFQUERY tag such as this:
<cfquery name="query1" datasource="dynamic">
SELECT name FROM people
IN '\\moya\shared\ugrad\ma123az\my_db.mdb'
</cfquery>
A name could be inserted into the people table
using a CFQUERY tag like the following,
which gets the value for the name column
from a form element called Form.name:
<cfquery name="query2" datasource="dynamic">
INSERT INTO people (name)
IN '\\moya\shared\ugrad\ma123az\my_db.mdb'
VALUES ('#Form.name#')
</cfquery>
Note the use of the datasource name dynamic.
Note also that the full path to the location of your *.mdb files
on the server must be specified. All undergraduate students in the
Department of Computing should refer to their home directories
as sub-directories of \\moya\shared\ugrad,
as described in the example above.
|