<%@ LANGUAGE=VBSCRIPT%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>THANKS FOR YOUR SUPPORT</title>
</head>
<body bgcolor="#CCFFFF">
<%
dim myconn
set myconn=Server.CreateObject("ADODB.Connection")
set rs=Server.CreateObject("ADODB.Recordset")
constr="provider=microsoft.jet.oledb.4.0;Data Source=" & server.MapPath("user.mdb")
myconn.open constr
rs.Open "select ID from login",myconn,1,1'更改打开记录集的方式获得记录总数
if not rs.eof then
totoaliq = rs.RecordCount
Dim num()'动态数组
Dim i
ReDim num(totoaliq)'初始化动态数组确定数组元素的个数,rs.RecordCount返回当前记录集有多少条记录。
i=0
Do Until rs.EOF
num(i)=rs("id")
i=i+1
rs.movenext
Loop
end if
rs.close
randomize
for i=0 to totoaliq-1
c=Round(rnd*totoaliq)
if i >0 then
for k=0 to i-1
while num(i)=c'碰到随即产生的值,那么重新再产生一次,至到该值与前面的随即值不同为止。
c=Round(rnd*totoaliq)
i=i+1
wend
next
end if
num(i) = c
rs.open "select * from login where id ="&num(i)
if not rs.eof then
response.write ("name is:"&rs("EngName")&"<br>")
end if
rs.close
next
set rs=nothing
myconn.close
set myconn=nothing
%>
</body>
</html>
随机产生随机值,显示的结果仍然有相同的名字取出。