이번 예제는 도움이 될까해서 해외사이트에서 퍼온 소스입니다.

참고하세요.


<%


    Dim eConn, ePath, rs,Sql,my_count
    Set eConn = Server.CreateObject("ADODB.Connection")
    ePath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("YOUR DB!")
   
    eConn.Open ePath
    'Count the records to get a High number
    Sql = "select count(b_id)as cnt from tblbanner"
   
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open Sql, eConn, 3, 3
    'plug it into a varibale
    my_count = rs("cnt")
 


    'If the table is empty write something
    if my_count < "1" Then
     Response.Write("Empty banner text")
    else
    'Get the ID and the Text for the banner
     Sql = "select b_id,b_text from tblbanner"
     Set rs = Server.CreateObject("ADODB.Recordset")
     rs.Open Sql, eConn, 3, 3
     RANDOMIZE
     Small = 1
    'vaiable for the high number
     High = my_count
     RandomNumber = INT((High-Small+1)*Rnd+Small)
    'Loop thru the results
     Do While Not rs.EOF
     Select Case RandomNumber
    'when the random number has a match us i
    '     t
      Case rs("b_id")
    'write the random number text
       Response.Write(rs("b_text"))
      End Select
     rs.MoveNext
     Loop
    End if
   
%>

2008/02/21 15:15 2008/02/21 15:15

Trackback Address :: 이 글에는 트랙백을 보낼 수 없습니다