展开全部
//数据库连接
<%
dim conn
dim connstr
dim db
db=""&ggjjdb_All&"" '设定数据名称,建议改成.asp
dim dbset:setdb = 1 '设定连接类型
On error resume next
Set conn = Server.CreateObject("ADODB.Connection")
select case setdb
case "1"
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
case "2"
connstr="driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath(""&db&"")
case "3"
connstr="driver={SQL Server};server=localhost;UID=sa;PWD=123;database=ggdata"
case else
connstr= "Dns=ggdata"
end select
if err.number>0 then
err.clear
set conn=nothing
response.write "数据库连接出错!"
Response.End
else
conn.open connstr
if err then
err.clear
set conn=nothing
response.write "数据库连接出错!"
Response.End
end if
end if
Sub CloseConn()
conn.close
set conn=nothing
End sub
%>
//滚动显示
<table width="195" height="98" border="0" cellpadding="0" cellspacing="0" style="border:1px #0099FF solid;">
<tr>
<TD height=20><div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="200" height="28" background="images/1/index_06.gif">
<tr>
<td width="5" height="25"> </td>
<td width="30"> </td>
<td valign="bottom"> </td>
<td width="45"> </td>
<td width="6"> </td>
</tr>
</table>
</div></TD>
</tr>
<tr>
<td height="146" ><marquee direction="up" scrollamount="1" scrolldelay="20" onMouseOut="this.start()" onMouseOver="this.stop()">
<table width="200" border="0" cellpadding="0" cellspacing="0"border:1px #0099FF solid;">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
set rs=server.createobject("adodb.recordset")
sql="select top 8 * from gonggao ORDER BY id DESC"
rs.open sql,conn,1,1
if Rs.eof or Rs.bof then
response.write"<div align='center'>没有内容<div>"
end if
do while not rs.eof
title = rs("title")
%>
<tr >
<td width="5%" height =25 background="images/table_bg2.gif"><img src="Images/zf11_Guide.gif" width="11" height="11"></td>
<td width="63%" height =25 background="images/table_bg2.gif"><a href="zf11_gonggao.asp?id=<%response.write rs(0)%>" title="<%=title%>">
<%
if Getlen(title)>30 then
response.write LeftStr(title,23)
response.write "..."
else
response.write ""&title&""
end if
%>
</a> </td>
</tr>
<%
rs.movenext
loop
Rs.Close
Set Rs=Nothing
%>
</table></td>
</tr>
</table>
</marquee></td>
</tr>
<tr>
<td height=3 valign="top" > </td>
</tr>
</table>
<%
dim conn
dim connstr
dim db
db=""&ggjjdb_All&"" '设定数据名称,建议改成.asp
dim dbset:setdb = 1 '设定连接类型
On error resume next
Set conn = Server.CreateObject("ADODB.Connection")
select case setdb
case "1"
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
case "2"
connstr="driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath(""&db&"")
case "3"
connstr="driver={SQL Server};server=localhost;UID=sa;PWD=123;database=ggdata"
case else
connstr= "Dns=ggdata"
end select
if err.number>0 then
err.clear
set conn=nothing
response.write "数据库连接出错!"
Response.End
else
conn.open connstr
if err then
err.clear
set conn=nothing
response.write "数据库连接出错!"
Response.End
end if
end if
Sub CloseConn()
conn.close
set conn=nothing
End sub
%>
//滚动显示
<table width="195" height="98" border="0" cellpadding="0" cellspacing="0" style="border:1px #0099FF solid;">
<tr>
<TD height=20><div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="200" height="28" background="images/1/index_06.gif">
<tr>
<td width="5" height="25"> </td>
<td width="30"> </td>
<td valign="bottom"> </td>
<td width="45"> </td>
<td width="6"> </td>
</tr>
</table>
</div></TD>
</tr>
<tr>
<td height="146" ><marquee direction="up" scrollamount="1" scrolldelay="20" onMouseOut="this.start()" onMouseOver="this.stop()">
<table width="200" border="0" cellpadding="0" cellspacing="0"border:1px #0099FF solid;">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
set rs=server.createobject("adodb.recordset")
sql="select top 8 * from gonggao ORDER BY id DESC"
rs.open sql,conn,1,1
if Rs.eof or Rs.bof then
response.write"<div align='center'>没有内容<div>"
end if
do while not rs.eof
title = rs("title")
%>
<tr >
<td width="5%" height =25 background="images/table_bg2.gif"><img src="Images/zf11_Guide.gif" width="11" height="11"></td>
<td width="63%" height =25 background="images/table_bg2.gif"><a href="zf11_gonggao.asp?id=<%response.write rs(0)%>" title="<%=title%>">
<%
if Getlen(title)>30 then
response.write LeftStr(title,23)
response.write "..."
else
response.write ""&title&""
end if
%>
</a> </td>
</tr>
<%
rs.movenext
loop
Rs.Close
Set Rs=Nothing
%>
</table></td>
</tr>
</table>
</marquee></td>
</tr>
<tr>
<td height=3 valign="top" > </td>
</tr>
</table>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询