» 首页 » 电脑_数码 » 编程 » asp读取access数据库主题

asp读取access数据库主题

我需要在网站首页用asp读取留言本的最后四个留言的主题
留言本位置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数据库主题
·asp.net堆栈跟踪
·我发觉我语言表达有问题,怎么办?
·SQL SERVER 服务器中,如何查询所有的数据库?并把数据库...
·怎样用asp判断一个URL地址是否存在有效??
·随滚动条上下移动的flash代码
·vs2005 网站开发的控件定义文件在哪里
·求php集成安装包( 优化、安全设置)都做好了的
·php代码 在自己的电脑上运行 需要什么
·VBS如何执行带\"\"的cmd命令
·SQL高手快来啊!!!
·紧急!!!编写程序:输入一行字符,统计其有多少个单词,单词...
·matlab对一维数组进行量化和归一化
·VFP高手帮忙蛤~~
·关于数据库:临时关系的名词解释

 《asp读取access数据库主题》答案收集时间:2008-06-14 14:47:42



©2007 电脑技术问答录