湘潭有什么槟榔:asp 无法显示数据库内容?

来源:百度文库 编辑:中科新闻网 时间:2024/05/09 03:06:44
库内表news列有 id art name content ctame
我要在news调用 name art ctame

但是显示没有数据

代码如下
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="260"> </td>
<td><table width="500" border="0" cellspacing="0" cellpadding="0"> <% Language="VBScript"
dim conn
dim connstr
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim sql
dim rs
on error resume next
'打开数据库

set conn=server.createobject("adodb.Connection")
conn.Open "provider=sqloledb;data source=10.1.1.1;uid=fc;pwd=123;database=fc1"
set rs=Server.CreateObject("ADODB.recordset")

'定义每页文章显示数
const MaxPerPage=18
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
sql="select * from news order by art_id desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,0,1,1
art_id=replace(rs("art_id"),chr(10)+chr(13),"<br>")
if rs.eof and rs.bof then
response.write "<p align='center'> 还没有任何留言</p>"
else totalPut=rs.recordcount '数据库中留言数totalput
if currentpage<1 then
currentpage=1
end if
'统计总页数currentpage
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showpage totalput,MaxPerPage,"news.ASP"
showContent
showpage totalput,MaxPerPage,"news.ASP"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showpage totalput,MaxPerPage,"news.ASP"
showContent
showpage totalput,MaxPerPage,"news.ASP"
else currentPage=1
showpage totalput,MaxPerPage,"news.ASP"
showContent
showpage totalput,MaxPerPage,"news.ASP"
end if
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
dim i
i=0
do while not rs.eof
%>

rs.open sql,0,1,1
改成rs.open sql,conn,1,1