- ASP - Random Functions
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·What's New?
Mail List


Random Db Observation
Most random content scripts involve the loading of arrays to call the one that you want to output. As the number of items you want to display randomly increases so may your need to serve them from a database rather than from large amounts of manually updated text files. The following code will select a random quote from the opening of the Simpsonís as well as display the observation number and the total number of observations found from the query.
View the Output
Text View
Print View
Mail this Link
Download the Code
View the Data

' Create a connection to the Access db and select all observations
' where there was a blackboard at the show opening
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
set rs = Server.CreateObject("ADODB.Recordset")
sql = "select blackboard from shows where blackboard <> '' " 
rs.Open sql, cn, 1, 3

' Sets total_records to the number of observation found

' Creates a random number from 1 to the total number of records found

' Move to the first record

' Start a loop that will continue until the random observation is found 
do while not rs.eof and counter <> random_number

' count the observations
counter = counter + 1 

' If the current observation = the random number out it
if counter= random_number then
response.write rs("blackboard") & "<br>"
response.write "Observation # " & random_number &" of " & total_records
end if ' end check for random observation

' Move to the next record

' Loop back to the for statement




ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement is hosted by
    Donate Food Online with a Mouse Click at
    Donate Land Online with a Mouse Click at
    © 1999 - 2018
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3