<%
' ADO Constant. Dont change this
Const adCmdText2 = &H0001
dim favoriteRandom1
dim favoriteRandom2
dim favoriteRandom3
dim favoriteRandom4
dim favoriteRandom5
dim favoriteRandom6
favoriteRandom1 = -1
favoriteRandom2 = -1
favoriteRandom3 = -1
favoriteRandom4 = -1
favoriteRandom5 = -1
favoriteRandom6 = -1
' Connection string and SQL statement
Dim query2, connStr2
connStr2 = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("ocm/cateringdb.mdb")
counter = 1
while counter <= 6
query2 = "select DISTINCT ProductName, highlight, Category, ID, Category from Products WHERE Highlight = true and ProductName not in ('" & favoriteRandom1 & "','" & favoriteRandom2 & "','" & favoriteRandom3 & "','" & favoriteRandom4 & "','" & favoriteRandom5 & "','" & favoriteRandom6 & "')"
' Opening database
Dim rs2
Set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.Open query2, connStr2, 3, , adCmdText2
' Generating random number from total number of records
Dim intRnd2
Randomize Timer
intRnd2 = (Int(RND * rs2.RecordCount))
if rs2.RecordCount > 0 then
' Now moving the cursor to random record number
rs2.Move intRnd2
if counter = 1 then
favoriteRandom1 = rs2("ProductName")
end if
if counter = 2 then
favoriteRandom2 = rs2("ProductName")
end if
if counter = 3 then
favoriteRandom3 = rs2("ProductName")
end if
if counter = 4 then
favoriteRandom4 = rs2("ProductName")
end if
if counter = 5 then
favoriteRandom5 = rs2("ProductName")
end if
if counter = 6 then
favoriteRandom6 = rs2("ProductName")
end if
' Showing the random statement
if rs2("Category") = 1 then
Response.Write "