In This Site

Home
Free News Updates
Using Microsoft FrontPage
Cascading Style Sheets
Database Fundamentals
FrontPage & Access
FrontPage Navigation
Website Security
Solving Problems
Learning SQL
Code Samples
Promote Your Site

In This Section

Up
CDONTS
Database Connections
Add to Database
Database & Email

The number one source  for making your website sell!

 

Creating a Database Connection Using ASP and ActiveX Data Objects (ADO)

In this tutorial, we'll learn how to create a basic database connection that will allow you to display values currently stored in a database. Again, this example is based upon the assumption that you are using Microsoft Access as your database and Microsoft FrontPage as your web development program.

While Active Server Pages (ASP) represents the computer code that we will use to access our database, ActiveX Data Objects (ADO) is something completely different. It is a set of objects created to simplify the process of connecting to data sources. It is NOT restricted to ASP. It is available to programmers using Visual C++, Java and Visual Basic. It is built into Microsoft Internet Information Server (IIS) so it is also available to any Microsoft hosted website.

Essentially ADO is a set of data access objects that sits between your ASP code and your database to simplify your data access.

For this example, we have created a database called FPTutorials.mdb and created a connection called FPTutorials. The table we will be viewing is called tAddRecordsTutorial. 

In order to view database table records, you need to do several things.

  1. Declare the variables that you will be sending to the database
  2. Open a connection with your database
  3. Display the data
  4. Close the database connection

Tell the script that you will declare all variables by using Option Explicit and then declare your variables.

<%option explicit%>

Begin your web page by placing the html, head and body tags.

<HTML>
<HEAD>
<TITLE>Basic Database Connections</TITLE>
</HEAD>
<BODY>

Assign form values to variables, one for your database connection (objConn) and one for your recordset (objRS).

<%
Dim objConn, objRS

Open your database Connection. Change the Server.MapPath to match YOUR database. If you use the default fpdb directory that FrontPage recommends, then you will need to change just the name of the database connection.


objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"../fpdb/FPTutorials.mdb;" & _
"Persist Security Info=False"

Close your database connection.

Conn.Close
set conn=nothing
set rs = nothing

End your database code.

<%Response.end%>

</body>
</html>

<%
conn.close
set conn = nothing
%>

 


These tutorials are part of an upcoming training course called "FrontPage Magic - How To Create A Database Driven Website For Non-Programmers". Stay tuned for more details on this exciting new product.

Send your tips to .
All materials Copyright © Ward Cameron All Rights Reserved