ASP Tutorials

Display records from an SQL table

display_my_quotes.asp

<%@ language="VBScript" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ASP Test</title>

<style type="text/css">
<!
.quote {background: #F0F0E1; padding: 1em; font: 19px Georgia, Arial, "Times New Roman", Times, serif;}
.author {text-align: right; margin-bottom: 2em; font: 10px Verdana, Geneva, sans-serif;}
-->
</style>


</head>

<body>

<%

dim myDatabaseConnection
dim myServerConnection
dim myDatabaseRecord
dim myDatabaseQuery

myServerConnection="DRIVER={SQL Server}; SERVER=127.0.0.0; UID=xxxxxxxx; PWD=xxxxxxxx; DATABASE=xxxxxxxx"
myDatabaseQuery="SELECT * FROM my_quotes"

set myDatabaseConnection = Server.CreateObject("ADODB.Connection")
set myDatabaseRecord = Server.CreateObject("ADODB.recordset")

myDatabaseConnection.open myServerConnection
myDatabaseRecord.open myDatabaseQuery, myDatabaseConnection

if myDatabaseRecord.eof then
response.write ("No records found.")

else
do while not myDatabaseRecord.eof
response.write "<div class=""quote"">" & myDatabaseRecord("quote") & "</div>"
response.write "<div class=""author"">" & myDatabaseRecord("first_name") & " "
response.write myDatabaseRecord("last_name") & "</div>"
myDatabaseRecord.moveNext
loop
end if

myDatabaseRecord.close
set myDatabaseRecord=nothing
myDatabaseConnection.close
set myDatabaseConnection=nothing
%>


</body>
</html>

my_quotes.asp
I am beginning to suspect all elaborate and special systems of education. They seem to me to be built up on the supposition that every child is a kind of idiot who must be taught to think.
Anne Sullivan
Creativity is a type of learning process where the teacher and pupil are located in the same individual.
Arthur Koestler
Education is a better safeguard of liberty than a standing army.
Edward Everett
Education is what remains after one has forgotten everything he learned in school.
Albert Einstein
ASP Tutorials
Other Tutorials