Display Access DB

This example shows how to display an Access database in a table

Here is our code.

<%
'our ADO constants
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adCmdTable = 2
Dim objConn , objRS
'create an ADO connection
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
'connection string with the path to our Database and driver . Note this is for Access
objConn.Open "DBQ=" & Server.MapPath("sampledb.mdb")& ";Driver={Microsoft Access Driver (*.mdb)}"
objRS.Open "tblSample", objConn , adOpenForwardOnly, adLockReadOnly, adCmdTable
'display a table with our data . Looping through the recordset until we reach the end of file EOF
%>
<TABLE>
<%
Do While Not objRS.EOF
%>
<tr>
<td><%=objRS.Fields("id").Value %></td>
<td><%=objRS.Fields("url").Value %></td>
<td><%=objRS.Fields("desc").Value %></td>
</tr>
<%
objRS.MoveNext
Loop
%>
</table>
<%
'close objects and set them to nothing
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>



Download the database here . (Use Right-Click then Save target as )

Sponsors