ASP Database Tutorial

Homepage > ASP Tutorials > ASP Database Tutorial

This tutorial will get you started with ASP databases using Microsoft Access, guiding you through the process from the start.

Once you know how to connect to a database, the following tutorials will show you how to add, update and delete records.

We'll begin this tutorial by looking at how we can connect to our database. You might already have an ODBC DSN set up:

<%
  Set oConn = Server.CreateObject("ADODB.Connection")
  oConn.Open "DSN=Users"
%>

However, the Access ODBC driver is known to cause problems when multiple users are connected.

If you know the physical path to your database on the server, it's better to bypass ODBC completely and connect using the Jet OLEDB Provider:

<%
  sPathToDB = "C:\Inetpub\Private\Database.mdb"

  Set oConn = Server.CreateObject("ADODB.Recordset")
  oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPathToDB & ";"
%>

Now our database connection is open we can go about modifying or viewing its contents. Once we're finished, we should ALWAYS close and destroy the database connection object:

<%
  oConn.Close
  Set oConn = Nothing
%>

So now we know how to connect to a database using ASP. In the next tutorial, we'll learn how to Add records to databases.

Related links

Rate this tutorial!

  • Currently 2.8/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Rated 2.8/5 stars (399 votes cast)

Make an enquiry

Privacy policy