Data | database | random <%
"An example of a random reading of a record from a database
Set Rs1=server. CreateObject ("Adodb.recordset")
Set Rs=server. CreateObject ("ADODB.") RECORDSET ")
Sql= "Select ID from Article ORDER by id DESC"
Rs. Open sql,dataconn,3,3
If not Rs. EOF Then
TOTAL=RS ("id") takes the largest ID
Rs. Close
Randomize
R=int ((total-1+ 1) * Rnd + 1)
Sql= "Select id,content from Article where id=" & R
Rs. Open sql,dataconn,3,3
If not Rs. EOF Then
Content=rs ("content")
Content=replace (CONTENT,CHR), "<br>"
Content=replace (CONTENT,CHR), "<br>"
Content=replace (Content, "<br><br>", "<br>")
Response.Write Content
Else
sql1= "Select content from Article"
Rs1. Open sql1,dataconn,3,3
If not EOF then
"Take the first record as the default display record
Content=rs1 ("content")
Content=replace (CONTENT,CHR), "<br>"
Content=replace (CONTENT,CHR), "<br>"
Content=replace (Content, "<br><br>", "<br>")
Response.Write Content
Else
The database is empty
Response.Write "does not exist"
End If
Rs1. Close
End If
Rs.close
End If
Set rs=nothing
%>