无法读取数据,求救!
我正在做一个网站。后台程序已经完成,可在前台程序上出了问题。我不知道如何解决。请各位大侠帮忙!
程序如下:
<%
set rs=server.CreateObject("adodb.recordset")
sql="select top 2 * from news order by id desc"
rs.open sql,conn,1,1
%>
<table width="100%" height="225" border="0">
<%
if rs.eof then
%>
<tr>
<td>暂时没有新闻!
</td>
</tr>
<%else
i=0
do while not rs.eof
%>
<tr>
<td>
<%=cutstr(rs("title"),22)%>
</td>
</tr>
<%rs.movenext
i=i+1
if i=2 then exit do
loop
rs.close
end if
%>
</table>
conn为:
dim conn
dim connstr
dim db
db="DataBase/mydata.mdb" '数据库文件位置
on error resume next
connstr="DBQ="+server.mappath(""&db&"")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
if err then
err.clear
else
conn.open connstr
end if
数据库路径正确无误