首页 | 免费域名 | 个人服务器 | 一流信息监控拦截系统 | 虚拟主机知识库 | ASP 空间 | ASP技术大全 | 下载中心 | 客户服务中心
  7i24 > ASP技术大全 > 代码乐园 >
    7i24 .Com  
  从数据库 随机 选取一条记录的实现

7i24.Com不停为您服务


' This script was obtained from the Infinite Monkeys Code library at
http://infinitemonkeys.atrax.co.uk
' to re-use, you must keep this text block intact
' copyright (c) Jason Brown/Atrax Internet 2000

' You may modify this script for your own use, keeping this notice
intact

set objCON = Server.CreateObject("ADODB.Connection")
objCON.open ""        ' add your dsn here ie :
objCON.open "myDSN"
set objRS = Server.CreateObject("ADODB.Recordset")

objRS.open "SELECT * FROM table", objCON, 3, 1 ' replace with your
own SQL statement

Dim rndMax
rndMax = CInt(objRS.RecordCount)

amRS.MoveFirst

Dim rndNumber
Randomize Timer
rndNumber = Int(RND * rndMax)

objRS.Move rndNumber

' carry out your action here, with the appropriate recordset index
' for example Response.Redirect(objRS("url")) (requires
Response.Buffer = true
' or response.write("<img src=" & objRS("img") & ">")


  2002年1月14日  阅读 1638 次  发送此页给朋友  来源:    版权争议  删除

相关文章:   近期热点:

上一篇: 字符串处理例子 - 获得文件的文件名和扩展名的函数
下一篇: ADO如何使用SQL函数
返回上一层...
搜索:

(C)2004-2022 7i24.Com 保留所有权利