Here’s the first part of the tutorial I’ll write about an application that can collect data,
store it in a DB, modify it and delete it.
First we’ll create all the prerequisites:
1. Creating our workspace
First create a new folder anywhere you want in your HD. Open the IIS and then create
a Virtual Directory, name it anything you like and point it to the folder created previously.
2. The database
For the sake of this tutorial we’ll use Access. It will work with SQL Server if you change the connection data.
Let’s create a Blank Database named example.mdb with the following tables:
|
USERS |
DETAILS |
|
ID (AutoNumber)
Name (text)
LastName (text)
Email (text)
Password (text)
|
ID_Detail
ID (Number)
Request (Text)
Date_Requested (Date/Time)
Comments (Memo) |
Fill both tables with a few entries. Remember the ID field in the DETAILS table must exist in the USERS table.
3. Set the connection stuff
We’ll store the connection information in a file named DBInfo.asp
Here’s the code:
<%
Dim strConnect
strconnect= "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\YourFolder\example.mdb;
Persist Security Info=False"
%>
<!-- METADATA NAME="Microsoft ActiveX Data Objects 2.5 Library" TYPE="TypeLib"
UUID="{00000205-0000-0010-8000-00AA006D2EA4}" -->
Now we’re ready to first our first page, we’ll name it listing.asp
<% Option Explicit %>
<!-- #INCLUDE FILE="DBInfo.asp" -->
<HTML>
<HEAD><TITLE>Users listing</TITLE></HEAD>
<BODY>
<%
Dim objRS
Set objRS = Server.CreateObject ("ADODB.Recordset")
objRS.Open "Users", strConnect, adOpenForwardOnly, adLockReadOnly, adCmdTable
response.write "<table width='400' border='1'><tr><td><b>User ID</b></td>" & _
"<td><b>Full Name</b></td><td><b>Email</b></td></tr>"
While Not objRS.EOF
Response.Write "<tr><td>"
Response.Write objRS("ID") & "</td><td>" &objRS("Name") & " "&objRS("Lastname")& _
"</td><td>"&objRS("Email")&"</td></tr>"
objRS.MoveNext
Wend
response.write "</table"
objRS.Close
Set objRS = Nothing
%>
</BODY></HTML>
This code will generate a table with a row for every single record on our database!!!
In the second part of this series we will learn how to add users to this table!