webmarkart
11-17-2003, 01:59 PM
I am trying to randomly select 3 records from an Access database and display them. I know what the problem is so far, but I'm unsure of how to fix it. I'm calling rs.RecordCount before I declare what rs is equal to.... here is the code so far:
<%
sql = ""
sql = sql & "SELECT LICENSE_NO,COMPANY,FNAME,LNAME,CITY,PHONE "
sql = sql & "FROM members "
MaxNumber = (rs.RecordCount) 'Highest Number from Record Count
Randomize 'To make sure its random
intrandomNum1 = Int(MaxNumber * Rnd) + 1
Randomize 'To make sure its random
intrandomNum2 = Int(MaxNumber * Rnd) + 1
Randomize 'To make sure its random
intrandomNum3 = Int(MaxNumber * Rnd) + 1
sql = sql & "WHERE LICENSE_NO = '" & intrandomNum1 & "' "
sql = sql & "OR LICENSE_NO = '" & intrandomNum2 & "' "
sql = sql & "OR LICENSE_NO = '" & intrandomNum3 & "' "
sql = sql & "ORDER BY LNAME asc "
Response.write sql
Set rs = oConn.Execute(sql)
%>
I need to change the Where and Or statements to
where record = (not LICENSE_NO = ) but I am also unsure of the syntax for this too...
Anyone know the proper syntax?
<%
sql = ""
sql = sql & "SELECT LICENSE_NO,COMPANY,FNAME,LNAME,CITY,PHONE "
sql = sql & "FROM members "
MaxNumber = (rs.RecordCount) 'Highest Number from Record Count
Randomize 'To make sure its random
intrandomNum1 = Int(MaxNumber * Rnd) + 1
Randomize 'To make sure its random
intrandomNum2 = Int(MaxNumber * Rnd) + 1
Randomize 'To make sure its random
intrandomNum3 = Int(MaxNumber * Rnd) + 1
sql = sql & "WHERE LICENSE_NO = '" & intrandomNum1 & "' "
sql = sql & "OR LICENSE_NO = '" & intrandomNum2 & "' "
sql = sql & "OR LICENSE_NO = '" & intrandomNum3 & "' "
sql = sql & "ORDER BY LNAME asc "
Response.write sql
Set rs = oConn.Execute(sql)
%>
I need to change the Where and Or statements to
where record = (not LICENSE_NO = ) but I am also unsure of the syntax for this too...
Anyone know the proper syntax?