下面的例子每隔60秒刷新一次,即检索一次数据库,如果有数据,则输出有音乐背景的页面:<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">
<META HTTP-EQUIV="Refresh" CONTENT="60">&nbsp;
<title>New Page 1</title>
<%
'建立数据库连接
Set myConn = Server.CreateObject(&quot;ADODB.Connection&quot;)&nbsp;<br>    
strConn = &quot;Provider=sqloledb; User ID=登录用户名; Password=该用户登录密码; Initial Catalog=数据库名称; Data Source=服务器IP地址"&nbsp;<br>     
myConn.Open strConn<br>      sql = "select * from tmessages where 这里写你的检索条件"
set rs=myConn.execute(sql)
if  rs.eof then'表示有数据
response.write "<bgsound src='你的音乐文件名.wav' loop=-1>"
end if
rs.close
set rs=nothing
myConn.close
%>
</head>
<body >
这里写你的其它代码
</body>
</html>

解决方案 »

  1.   

    上面的这个有代码错误,你试试下面这个:
    下面的例子每隔60秒刷新一次,即检索一次数据库,如果有数据,则输出有音乐背景的页面:下面的例子每隔60秒刷新一次,即检索一次数据库,如果有数据,则输出有音乐背景的页面:<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">
    <META HTTP-EQUIV="Refresh" CONTENT="60"> 
    <title>New Page 1</title>
    <%
    '建立数据库连接
    Set myConn = Server.CreateObject("ADODB.Connection")    
    strConn = "Provider=sqloledb; User ID=登录用户名; Password=该用户登录密码; Initial Catalog=数据库名称; Data Source=服务器IP地址"
    myConn.Open strConn    sql = "select * from tmessages where 这里写你的检索条件"
    set rs=myConn.execute(sql)
    if  rs.eof then'表示有数据
    response.write "<bgsound src='你的音乐文件名.wav' loop=-1>"
    end if
    rs.close
    set rs=nothing
    myConn.close
    %>
    </head>
    <body >
    这里写你的其它代码
    </body>
    </html>