Mysql ASP:EOF或BOF都是真的,但我有记录,它们正在显示
我有一个大约有40条记录的数据库,我试图用3列的表格方式显示它们,但扩展到了记录的范围 所有的记录都会显示出来,但当它到达记录列表的最末端时,我会看到另一个单元格,并显示以下消息: ADODB.字段错误“800a0bcd”BOF或EOF为真,或当前 记录已被删除。请求的操作需要当前的 记录/products/index1.asp,第668行 在中,我将在下面发布代码,有人能帮忙吗,我已经在网上搜索过了,但什么也找不到。这是我能找到的在3宽表中显示记录的唯一方法,如果有更好的方法,即使使用CSS,也将不胜感激Mysql ASP:EOF或BOF都是真的,但我有记录,它们正在显示,mysql,vbscript,asp-classic,repeat,Mysql,Vbscript,Asp Classic,Repeat,我有一个大约有40条记录的数据库,我试图用3列的表格方式显示它们,但扩展到了记录的范围 所有的记录都会显示出来,但当它到达记录列表的最末端时,我会看到另一个单元格,并显示以下消息: ADODB.字段错误“800a0bcd”BOF或EOF为真,或当前 记录已被删除。请求的操作需要当前的 记录/products/index1.asp,第668行 在中,我将在下面发布代码,有人能帮忙吗,我已经在网上搜索过了,但什么也找不到。这是我能找到的在3宽表中显示记录的唯一方法,如果有更好的方法,即使使用CSS,
<table border="0">
<tr><td class="product_title">Our Products</td></tr>
<tr><td colspan="5" height="7"></td></tr>
<% While ((Repeat1__numRows <> 3) AND (NOT products_page.EOF)) %>
<tr>
<td align="center" valign="middle">
<div class="thumbgrey" align="center">
<a href="/products/<%=(products_page.Fields.Item("" & lang & "_URL").Value)%>" title="<%=(products_page.Fields.Item("" & lang & "_title").Value)%>">
<img src="/images/product_page/<%=(products_page.Fields.Item("" & lang & "_image").Value)%>" alt="<%=(products_page.Fields.Item("" & lang & "_title").Value)%>" width="230" height="97" border="0" />
</a>
</div>
</td>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
products_page.MoveNext()
%>
<td align="center" valign="middle">
<div class="thumbgrey" align="center">
<a href="/products/<%=(products_page.Fields.Item("" & lang & "_URL").Value)%>" title="<%=(products_page.Fields.Item("" & lang & "_title").Value)%>">
<img src="/images/product_page/<%=(products_page.Fields.Item("" & lang & "_image").Value)%>" alt="<%=(products_page.Fields.Item("" & lang & "_title").Value)%>" width="230" height="97" border="0" />
</a>
</div>
</td>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
products_page.MoveNext()
%>
<td align="center" valign="middle">
<div class="thumbgrey" align="center">
<a href="/products/<%=(products_page.Fields.Item("" & lang & "_URL").Value)%>" title="<%=(products_page.Fields.Item("" & lang & "_title").Value)%>">
<img src="/images/product_page/<%=(products_page.Fields.Item("" & lang & "_image").Value)%>" alt="<%=(products_page.Fields.Item("" & lang & "_title").Value)%>" width="230" height="97" border="0" />
</a>
</div>
</td>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
products_page.MoveNext()
Wend
%>
</tr>
</table>
我们的产品
发生这种情况是因为您的记录集不包含3行的倍数
尝试写入第二列或第三列时出现错误
试着这样做(我省略了图像的实际书写,因为它不相关):
...
您好,您应该将其添加到一个循环中,该循环在每三次输入后创建一个新行,这样您就不会重复编写同一代码3次,并且在更新代码时可以节省工作
<table border="0">
<tr><td class="product_title">Our Products</td></tr>
<tr><td colspan="3" height="7"></td></tr>
<tr>
<%
Repeat1__index = 1
Do While (NOT products_page.EOF)
%>
<td align="center" valign="middle">
<div class="thumbgrey" align="center">
<a href="/products/<%=(products_page.Fields.Item("" & lang & "_URL").Value)%>" title="<%=(products_page.Fields.Item("" & lang & "_title").Value)%>">
<img src="/images/product_page/<%=(products_page.Fields.Item("" & lang & "_image").Value)%>" alt="<%=(products_page.Fields.Item("" & lang & "_title").Value)%>" width="230" height="97" border="0" />
</a>
</div>
</td>
<%
Repeat1__index = Repeat1__index+1
If Repeat1__index = 4 Then
Response.Write("</tr><tr>")
Repeat1__index = 1
End If
products_page.MoveNext()
Loop
If Repeat1__index > 1 Then
Response.Write("<td colspan='" & 4-Repeat1__index & "'></td>")
End If
%>
</tr>
</table>
我知道Jan你刚刚重新格式化了OPs代码使其生效。但是@ 07LooGET请考虑使用<代码>如果不是产品,请将数据设置为“产品=产品”页.GETROWS()/代码>这样,您可以关闭内存不足的代码<代码> ADODB。记录集< /代码>,并使用2维<代码>数组< /代码>迭代您的数据,如您所见的“代码> GETROWS())/代码>返回一个2维的列数组,行,因此第一行中的第二列将是数据(1,0)
(数组中的所有序号都从0开始)。@07lodgeT还使用数组意味着使用Mod()
来处理每个
的
个数将是一个棘手的问题Mod()
非常适合这种类型,指定每行的列数并监视。所有代码和标记的重复都是不必要的。我能看到的唯一交易破坏者是使用产品页面.Fields.Item(“&lang&“\u URL”).Value
,因为这需要访问字段
元数据,而数组
将不包含这些元数据。
<table border="0">
<tr><td class="product_title">Our Products</td></tr>
<tr><td colspan="3" height="7"></td></tr>
<tr>
<%
Repeat1__index = 1
Do While (NOT products_page.EOF)
%>
<td align="center" valign="middle">
<div class="thumbgrey" align="center">
<a href="/products/<%=(products_page.Fields.Item("" & lang & "_URL").Value)%>" title="<%=(products_page.Fields.Item("" & lang & "_title").Value)%>">
<img src="/images/product_page/<%=(products_page.Fields.Item("" & lang & "_image").Value)%>" alt="<%=(products_page.Fields.Item("" & lang & "_title").Value)%>" width="230" height="97" border="0" />
</a>
</div>
</td>
<%
Repeat1__index = Repeat1__index+1
If Repeat1__index = 4 Then
Response.Write("</tr><tr>")
Repeat1__index = 1
End If
products_page.MoveNext()
Loop
If Repeat1__index > 1 Then
Response.Write("<td colspan='" & 4-Repeat1__index & "'></td>")
End If
%>
</tr>
</table>
products_page.Close()
Set products_page = Nothing