Northern Arizona University   Information Technology Services
  ITS Home ITS Index Faculty / Staff Services Student Services ITS Jobs Email Manager Contact ITS
 

 

 

 
 

Database Connectivity

The code below describes how to make a connection to your database on an ASP page. This technique can be used on all IIS servers, including www4 and www4dev, Oak, and Pine.

Connect to an Oracle database:
<%
'Declare the variable for the connection
dim conn
session.Timeout = 15
'Create the connection object
Set Conn = Server.CreateObject("ADODB.Connection")
'Open the database using the ODBC drivers
Conn.open("DRIVER={Microsoft ODBC for Oracle};SERVER=servername;UID=userID;PWD=password")
%>

Note that the two lines beginning with "Conn.open" should be one line in your code.

Connect to an Access database:
*NOTE* When connecting to an Access database it is best to contain the database in an fpdb folder in your web. This is the folder created when you import an Access database using FrontPage. The reason this is very important is because the fpdb folder sets permissions to the database but does not allow people to browse to the database. If the database is located outside of this folder, surfers can access the database.
<%
'Declare the variables for the connection
Dim Conn, URL, DBQ
URL=Server.MapPath("../fpdb/database.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="& URL)
%>

Note that the two lines beginning with "Conn.Open" should be one line in your code.

Back to the Web Developer's Hub
Blue horizontal bar
ADA Friendly Logo Web Page Contact: Ask-SW@nau.edu Northern Arizona University Logo
© 2003 Northern Arizona University - Information Technology Services