一个类似在线测试的试题,要求每次刷新页面都会显示数据库itemdatabase中不同的题目和答案,itemdatabase中有三个表项:id,question题目,answer答案,共30条记录,我写了以下程序,可不是显示乱码,就是错误,我是一个初学者,请高手们帮我看看,有什么语病了!
<%
set dbconnection=server.CreateObject("adodb.connection")
DBPath = Server.MapPath("DB\Data.mdb")
dbconnection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
randomize()
N=int(rnd(30))
set news_rs=dbconnection.execute("select * from itemdatabase where id="&N&"")
response.write news_rs("question")
response.write news_rs("anwser")
%>
<%
set dbconnection=nothing
%>
------解决方案--------------------
set news_rs=dbconnection.execute("select * from itemdatabase where id="&N&"")
While Not news_rs.EOF
response.write news_rs("question")
response.write news_rs("anwser")
news_rs.MoveNext
Wend
乱码可能跟你的页面编码设置有关系