|
| » 首页 » 电脑_数码 » 编程 » asp读取access数据库主题 |
asp读取access数据库主题 |
|
留言本位置book目录数据库/book/images/##bookyesitis.asp 数据库调取文件为config.asp <%on error resume next set conn=server.CreateObject("adodb.connection") DBPath = Server.MapPath("images/##bookyesitis.asp") conn.open "provider=microsoft.jet.oledb.4.0; data source="&DBpath function CloseDB Conn.Close set Conn=Nothing End Function ck="" jk="<a href=http://www.66369.net/ target=_blank>快捷留言簿</A>" downshou="Copyright (C) 2000-2099 All Rights Reserved</A>" banbenurl="<a href=http://www.66369.net/ target=_blank>" banbenname="v 10.09 正式版</A>" starttime=timer() set rs=conn.execute("SELECT * FROM gbinfo") LogName=rs("logname") LogPWD=rs("logpwd") show_style=rs("defaultstyle") Showlynum=rs("showlynum") siteurl= rs("siteurl") USRName= rs("username") popwrite=rs("popwrite") notice=rs("notice") ubbcode=rs("ubbcode") lylitmit=split(rs("lymax"),"|") lymax=cint(lylitmit(1)) lymin=cint(lylitmit(0)) shhe=rs("shhe") click=rs("visit") BottomStr=rs("BottomStr") 'http://www.66369.net %> 数据库表为:gb,主题:title 现在要在网站首页中读取留言板的最新的四个留言主题(倒序id),同时在点击留言标题的时候链接到http://www.xxx.com/book/ 麻烦给出最详细的asp写法. 我的QQ:714175514.能够帮我解决这个问题我给200分,现在放出100.解决了再给100. |
![]() |
|
|
ssql="select * from gb order by id desc " set rs=server.CreateObject("adodb.recordset") rs.open ssql,con,1,1 n=4 do while not rs.eof and n>0 n=n-1 id=rs("id") title=rs("title") response.Write("<a href='http://www.xxx.com/book/?id="&id&"'>"&title&"</a><br>" rs.movenext loop %> 直接复制上试试,可能有的地方要该该 ssql="select * from gb order by id desc " set rs=server.CreateObject("adodb.recordset") rs.open ssql,con,1,1 n=4 do while not rs.eof and n>0 n=n-1 id=rs("id") title=rs("title") response.Write("<a href='http://www.xxx.com/book/?id="&id&"'>"&title&"</a><br>" rs.movenext loop %> 直接复制上试试,可能有的地方要该该 select top 4 * from gb order by id desc set rs=conn.execute("SELECT top 4 * FROM gbinfo order by id desc") if rs.eof or rs.bof then response.write("还没有留言...") else do while not rs.eof response.write(表中的数据写到这地方) rs.movenext loop end if rs.close:set rs=nothing '读取留言板的最新的四个留言主题SQL语句写法为: <% ... set rs=conn.execute("SELECT * FROM gbinfo") '改为 set rs=conn.execute("SELECT top 4 * FROM gbinfo order by id desc") '使用top n选项可以限制返回的数据行数,top n说明返回n行 ... %> '///////////////////////////////////////////////////// '点击留言标题的时候链接到http://www.xxx.com/book/ 的写法为: <a href=# onclick="javascript:window.open('http://www.xxx.com/book/ ?id=<%=rs("id")%>')">留言标题</a> 哇!分数挺高的... |
| 《asp读取access数据库主题》答案收集时间:2008-06-14 14:47:42 |