asp随机读取数据

时间:2009-03-11    点击:1536   

sqlserver数据库很简单,一句代码搞定,比如: select * from news order by newid();

access数据库:

                <%
     set rs=server.createobject("adodb.recordset")
        sql="SELECT newsid,title FROM news  "
     rs.open sql,conn,1,1  
     count=rs.RecordCount
     Item=10
     redim a(Item ,2),t(count)
     for each j in t
       j=0
        next
         
       Randomize timer
       for j=1 to Item
                    k=int(rnd*count+1)
     do while t(k)<>0
     k=int(rnd*Item+1)
     loop
     t(k)=1
     next
     
     j=1:i=1
     do while not rs.eof
     if t(j)=1 then
     a(i,1)=rs("n_id")
     a(i,2)=rs("title")
     i=i+1
     end if
     j=j+1
     rs.movenext
     loop
        for i=1 to Item
    %>
     <a href="newsdetail.asp?newsid=<%=a(i,1)%>" target="_blank" class="bolded2"><%=a(i,2)%></a>
    <%


        next
     rs.close
     set rs=nothing
    %>

层居中
去掉超链接虚线
asp日历
asp隐藏图片真实路径
asp读取acccess数据库中全部表名,字段名,内容
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 All Rights Reserved