从数据库中读数据,每一行中显示三条不同的记录之后再循环一行代码怎么写?

fyjxfj 2003-08-28 01:46:35
从数据库中读数据,每一行中显示三条不同的记录之后,再循环一行代码怎么写?也就是说一个n行三列的表格,每个表格都显示从数据中读出来的不同记录
...全文
146 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
fyjxfj 2003-08-28
  • 打赏
  • 举报
回复
我需要一行中每一列显示不同的记录,我按上面的各位说的试了一下,一行都显示一样的了,我在嵌套循环的里面的那个循环加上rs.movenext就报如下错误:
ADODB.Recordset 错误 '800a0bcd'
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。

/more1.asp,行41

fyjxfj 2003-08-28
  • 打赏
  • 举报
回复
我改成一行显示一条记录就不会出错,显示三条就要出错,应该怎么办呢?
fyjxfj 2003-08-28
  • 打赏
  • 举报
回复
报错如下:ADODB.Recordset 错误 '800a0bcd'
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。

/more.asp,行60

suze1979 2003-08-28
  • 打赏
  • 举报
回复
镶套错误
do while
if....

do while

if...

else

....(在此无end if结束 if 语句)
loop(40行)
else

end if

loop
fyjxfj 2003-08-28
  • 打赏
  • 举报
回复
rs.movefirst这一句本来是rs.movenext
没改前这句报错
改过来之后脚本运行超时
fyjxfj 2003-08-28
  • 打赏
  • 举报
回复
<%
CatalogCode=Request.QueryString("pos")
set con=server.CreateObject ("ADODB.Connection")
set rs=server.CreateObject ("ADODB.Recordset")
con.Open Application("JzCon")
sqlstr="Select * from 文档 where Catalogcode='"&CatalogCode&"'and HaveInputed=True order by IssueTime desc"
rs.Open sqlstr,con,1,3
thestr=""
i=0
do while not rs.eof
DocTitle=trim(rs("Title"))
if rs("IsLink")=True then
thestr=thestr&"<tr>"
do while not rs.eof
if i<3 then
thestr=thestr&"<td><a href="&rs("DocFileName")&" target=_blank>"&DocTitle&"</a></td>"
else
exit do
end if
i=i+1
rs.movenext
loop
thestr=thestr&"</tr>"
else
thestr=thestr&"<tr>"
do while not rs.eof
if i<3 then
thestr=thestr&"<td><a href=/doc_template.asp?id="&rs("id")&"&file="&trim(rs("DocFileDir"))&trim(rs("DocFileName"))&"&docCatalog="&trim(rs("CatalogCode"))&" title="&DocTitle&" target=_blank>"&DocTitle&"</a></td>"
else
exit do
end if
i=i+1
rs.movenext
loop
thestr=thestr&"</tr>"
end if
rs.movefirst
i=0
loop
rs.Close
con.Close
set rs=nothing
set con=nothing
response.Write thestr
%>

我改过来了可是还是有错
不能执行
jz_bnx 2003-08-28
  • 打赏
  • 举报
回复
镶套错误
do while not rs.eof
if ...

else

end if
loop
fyjxfj 2003-08-28
  • 打赏
  • 举报
回复
<%
CatalogCode=Request.QueryString("pos")
set con=server.CreateObject ("ADODB.Connection")
set rs=server.CreateObject ("ADODB.Recordset")
con.Open Application("JzCon")
sqlstr="Select * from 文档 where Catalogcode='"&CatalogCode&"'and HaveInputed=True order by IssueTime desc"
rs.Open sqlstr,con,1,3
thestr=""
i=0
do while not rs.eof
if rs("IsLink")=True then
thestr=thestr&"<tr>"
do while not rs.eof
if i < 3 then
thestr=thestr&"<td><a href="&rs("DocFileName")&" target=_blank>"&DocTitle&"</a></td>"
else
exit do
i=i+1
rs.movenext
loop (此为40行)
thestr=thestr&"</tr>"
else
thestr=thestr&"<tr>"
do while not rs.eof
if i < 3 then
thestr=thestr&"<td><a href=/doc_template.asp?id="&rs("id")&"&file="&trim(rs("DocFileDir"))&trim(rs("DocFileName"))&"&docCatalog="&trim(rs("CatalogCode"))&" title="&DocTitle&" target=_blank>"&DocTitle&"</a></td>"
else
exit do
i=i+1
rs.movenext
loop
thestr=thestr&"</tr>"
end if
rs.movenext
i=0
loop
rs.Close
con.Close
set rs=nothing
set con=nothing
response.Write thestr
%>
报错为:Microsoft VBScript 编译器错误 错误 '800a040e'

'loop' 语句缺少 'do'

/more.asp,行40

loop

yzwxjun 2003-08-28
  • 打赏
  • 举报
回复
<% i=0
Do While Not RS.EOF and i<RS.PageSize%>
<tr>
<% for j=1 to 5
if rs.eof then
exit for
end if %>
要显示的内容
<% rs.movenext next %>
</tr> <% i=i+1
loop
%>
我的通过了
yzwxjun 2003-08-28
  • 打赏
  • 举报
回复
if not rs.eof then
rs.pagesize=4-------这里设置要显示多少行
if pg="" then
pg="1"
rs.absoluteposition=1
else
rs.absoluteposition=pg*5*rs.pagesize-19-----这里是每一行显示5个记录,设置下一行的起始号
end if
end if
fyjxfj 2003-08-28
  • 打赏
  • 举报
回复
我<td></td><tr></tr>的循环代码写出来之后老报错,所以现向各位高人征代码一用
61 2003-08-28
  • 打赏
  • 举报
回复
i = 0
while not rs.EOF
Response.write rs("fld")
i = i + 1
if i>3 then
i=0
end if
rs.movenext
wend
511214 2003-08-28
  • 打赏
  • 举报
回复
i = 0
do while not rs.EOF
Response.write "<tr>"
do while not rs.EOF
if i < 3 then
Response.write "<td>"
Response.write rs("fld")
Response.write "</td>"
else
exit do
end if
i = i + 1
rs.movenext
loop
i = 0
Response.write "</tr>"
loop
sdliubo 2003-08-28
  • 打赏
  • 举报
回复
做好<td></td><tr></tr>的循环控制

很简单的
xiaobaowu 2003-08-28
  • 打赏
  • 举报
回复
你在循环的时候设一个i,每一条纪录加1,
当i为3的整数倍的时候写<tr>....</tr>,否则只写<td>...<td>
不就行了吗.


xiaobird1 2003-08-28
  • 打赏
  • 举报
回复
给你一个例子。

只是一个意思,代码没有测试过,自己调调吧。

i = 0
do while not rs.EOF
Response.write "<tr>"
do while not rs.EOF
if i < 3 then
Response.write "<td>"
Response.write rs("fld")
else
exit do
end if
i = i + 1
rs.movenext
loop
i = 0;
Response.write "</tr>"
loop
fyjxfj 2003-08-28
  • 打赏
  • 举报
回复
一个n行三列的表格中,每个单元格中都显示从数据库中读出来的不同记录集,此代码如何写?

28,404

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧