The following code will return names and states from an access DB called Samples.mdb. Yoy can download the Access file from http://www.media-2000.com/samples.mdb
Make sure to set the "DSN=whatevername" to whatever you want. And you should be all set. Did I mention that the code is courtesy of Kathi at http://www.web-savant.com/users/kathi/default.htm
<html>
<head>
<title>ASP Sample Script</title>
</head>
<body bgcolor="#ffffff">
<center>
<table width=600 border=1 cellpadding=5 cellspacing=0>
<%
' first create a recordset object
set rs=Server.CreateObject("adodb.Recordset")
' next set up a connection string
connectme="DSN=whatevername"
' now set up a query for the database
sqlstmt = "SELECT * from Sample ORDER BY State DESC"
' connect to the database and execute query
rs.open sqlstmt, connectme
' if the recordset is empty we will quit
' and display a message using a conditional
' if...then...else statement
If rs.eof then
response.write "<center>"
response.write "There are no records"
response.write "<br>Please check back later"
response.write "</center>"
Else
response.write "<tr>"
response.write "<td colspan=4 align=""center"">"
response.write "<i><h1>Sample Script 1</a>"
response.write "</tr>"
' let's save some typing by setting start & end html
' for each cell to a variable
StartCell="<td><font size=2>"
EndCell="</font></td>"
With Response
.write "<tr>"
.write StartCell & "Name" & EndCell
.write StartCell & "City" & EndCell
.write StartCell & "State" & EndCell
.write StartCell & "Country" & EndCell
.write "</tr>"
End With
' loop through the records and display the information
' using a Do While...Loop statement
Do while not rs.eof
Name = rs("Name")
City = rs("City")
State = rs("State")
Country = rs("Country")
With Response
.write "<tr>"
.write StartCell & City & EndCell
.write StartCell & State & EndCell
.write StartCell & Country & EndCell
.write "</tr>"
End With
rs.MoveNext ' moves to next record
loop ' go get another record
End If
%>
</td>
</tr>
</table>
</center>
</body>
</html>
Mo