Generate random db record output. This is classic asp script. VB.NET version is coming soon
< % @ Language="VBScript" %>
< % Option Explicit %>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title>
<link href="Styles/Site.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="page">
<div class="main">
<div style="width: 900px; text-align: right;">
<input type="button" Value="Back to Home"
OnClick="window.location.href='http://my_website/home.aspx'"
class="button blue"/>
<%
'declare your variables
dim connection, recordset, sConnString, sql
dim intRandomNumber, intTotalRecords, i
'declare SQL statement that will query your database
sql = "SELECT * FROM ob_feedback"
'create ADO connection and recordset object
Set connection = Server.CreateObject("ADODB.Connection")
Set recordset = Server.CreateObject("ADODB.Recordset")
'define the connection string, specify database
' driver and the location of database
sConnString="PROVIDER=Microsoft.ACE.OLEDB.12.0; &_
Data Source=" & Server.MapPath("App_Data\ob_db.accdb")
'Open the connection to the database
connection.Open(sConnString)
'Open the recordset object executing the SQL
recordset.Open sql, connection, 3, 1
'count the number of records and hold this is the variable intTotalRecords
intTotalRecords = recordset.RecordCount
Randomize()
intRandomNumber = Int(intTotalRecords * Rnd)
'move to the random number returned
recordset.Move intRandomNumber
'open the table
'header
Response.Write("Drawing a winner")
'running a job
'def var
Dim job
job = Request.QueryString("do")
If job = "go" Then
Response.write("<table style='border: gray 1px solid;' ><tr>")
'loop through the total number of fields
For i = 0 to recordset.Fields.Count - 1
'write out the field value
Response.write("<td>" & recordset(i) & "")
Next
'close the table
response.write ""
End If
'close the recordset and connection objects and free up resources
recordset.Close
Set recordset=Nothing
connection.close
Set connection=Nothing
%>
<div style="min-height: 20px;">
<div style="width: 900px; text-align: center;">
<input type="button" Value="Generate"
OnClick="window.location.href='http://my_website/drawing.asp?do=go'"
class="button blue"/>
<div class="clear">
<div class="footer">
</body>
</html>