数据库搜索什么都找不到的错误 [英] error if db search finds nothing

查看:70
本文介绍了数据库搜索什么都找不到的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果数据库搜索找到至少一条

满足查询的记录,我的页面工作正常。

但是如果找不到匹配项我得到以下错误消息。


错误类型:

ADODB.Field(0x80020009)

BOF或EOF是True还是当前记录已删除。

请求的操作需要当前记录。


我需要在此处更改以使其显示页面

没有数据?


sSQL =" SELECT [结算日期],[服务号码],[订阅者用户

名称]," &安培; _

"基金,账户,[活动代码],描述,[总费用]" &安培; _

" FROM 06_Statements &安培; _

"在哪里[结算日期] =''" &安培; Request.Form(cmonth)& "" &安培; _

" AND [服务号码] =''" &安培; Request.Form(" cnumb")& "" &安培; _

" AND cstr([Total Charge])=''" &安培; cstr(Request.Form(" camount)))& "''"

set rs = Connect.Execute(sSQL)

<%

直到rs。 eof

%>

< tr>

< td><%= rs(" Service Number")%> ;< / td>

< td><%= rs(" Subscriber User Name")%>< / td>

< td> ;<%= rs(" Fund")%>< / td>

< td><%= rs(" Account")%>< / td> ;

< td><%= rs(" Activity Code")%>< / td>

< td><%= rs (" Description")%>< / td>

< td><%= rs(" Total Charge")%>< / td>

< / tr>

<%结束如果

rs.MoveNext

Loop%>

解决方案



abbyle ... @ hotmail.com写道:

我的页面工作正常如果数据库搜索找到至少一个满足查询的记录。
但如果不是f我找到以下错误消息。

错误类型:
ADODB.Field(0x80020009)
BOF或EOF为True,或者当前记录已被删除。
请求的操作需要当前的记录。

我需要在这里更改以使其只显示没有数据的页面?

sSQL =SELECT [帐单日期],[服务号码],[订户用户名称]," &安培; _
基金,账户,[活动代码],描述,[总费用]" &安培; _
FROM 06_Statements &安培; _
在哪里[结算日期] =''" &安培; Request.Form(cmonth)& "" &安培; _
AND [服务号码] =''" &安培; Request.Form(" cnumb")& "" &安培; _
AND cstr([Total Charge])=''" &安培; cstr(Request.Form(" camount)))& "''"
设置rs = Connect.Execute(sSQL)

<%
直到rs.eof
%>
< tr>
< td><%= rs(" Service Number")%>< / td>
< td><%= rs(" Subscriber User)名称")%>< / td>
< td><%= rs(" Fund")%>< / td>
< td><%= rs(帐户)%>< / td>
< td><%= rs("活动代码")%>< / td>
< td> ;<%= rs(" Description")%>< / td>
< td><%= rs(" Total Charge")%>< / td>
< / tr>
<%结束如果
rs.MoveNext
循环%>




如果不是rs .eof然后

直到rs.eof

%>

< tr>

< td> ;<%= rs(" Service Number")%>< / td>

< td><%= rs(" Subscriber User Name")%>< ; / td>

< td><% = rs(" Fund")%>< / td>

< td><%= rs(" Account")%>< / td>

< td><%= rs(" Activity Code")%>< / td>

< td><%= rs(" Description" ;)%>< / td>

< td><%= rs("总费用)%>< / td>

< / tr>

<%结束如果

rs.MoveNext

循环

其他

response.write"没有要显示的记录"

结束如果

%>


/ P 。




Paxton写道:

abbyle ... @ hotmail.com写道:< blockquote class =post_quotes>如果db搜索找到至少一条满足查询条件的记录,我的页面工作正常。
但如果找不到匹配,我会收到以下错误消息。错误类型:
ADODB.Field(0x80020009)
BOF或EOF为True,或者当前记录已被删除。
Re问题操作需要一个当前的记录。

我需要在这里做些什么来使这只显示没有数据的页面?

sSQL =" SELECT [结算日期],[服务号码],[订户用户名称]," &安培; _
基金,账户,[活动代码],描述,[总费用]" &安培; _
FROM 06_Statements &安培; _
在哪里[结算日期] =''" &安培; Request.Form(cmonth)& "" &安培; _
AND [服务号码] =''" &安培; Request.Form(" cnumb")& "" &安培; _
AND cstr([Total Charge])=''" &安培; cstr(Request.Form(" camount)))& "''"
设置rs = Connect.Execute(sSQL)

<%
直到rs.eof
%>
< tr>
< td><%= rs(" Service Number")%>< / td>
< td><%= rs(" Subscriber User)名称")%>< / td>
< td><%= rs(" Fund")%>< / td>
< td><%= rs(帐户)%>< / td>
< td><%= rs("活动代码")%>< / td>
< td> ;<%= rs(" Description")%>< / td>
< td><%= rs(" Total Charge")%>< / td>
< / tr>
<%结束如果
rs.MoveNext
循环%>



如果不是rs.eof那么<直到rs.eof
%>
< tr>
< td><%= rs(" Service Number")%>< / td> ;
< td><%= rs(" Subscriber User Name")%>< / td>
< td><%= rs(" Fund& quot;)%>< / td>
< td><%= rs(" Account")%>< / td>
< td><%= rs(活动代码)%>< / td>
< td><%= rs(" Description")%>< / td>
< td> ;<%= rs(" Total Charge")%>< / td>
< / tr>
<%End如果
rs.MoveNext
循环
其他
response.write没有要显示的记录
结束如果
%>

/P.




哎呀。我没有在你的代码中发现一个奇怪的''结束如果' - 就在

rs.movenext之前。你需要删除它 - 它没有任何意义我可以在片段中看到



/ P.


即使我删除了我的结束如果后仍然无法工作

我收到了错误:

错误类型:

Microsoft VBScript编译(0x800A040E)

''循环''没有''做'


my page works fine if the db search finds at least one record that
satifies the query.
but if it does not find a match I get the following error message.

Error Type:
ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

What do I need to change here to make this just display the page with
no data?

sSQL = "SELECT [Billing Date], [Service Number], [Subscriber User
Name]," & _
" Fund, Account,[Activity Code], Description, [Total Charge]" & _
" FROM 06_Statements" & _
" WHERE [Billing Date] = ''" & Request.Form("cmonth") & "''" & _
" AND [Service Number] = ''" & Request.Form("cnumb") & "''" & _
" AND cstr([Total Charge]) = ''" & cstr(Request.Form("camount")) & "''"
set rs = Connect.Execute(sSQL)

<%
Do until rs.eof
%>
<tr>
<td><%=rs("Service Number")%></td>
<td><%=rs("Subscriber User Name")%></td>
<td><%=rs("Fund")%></td>
<td><%=rs("Account")%></td>
<td><%=rs("Activity Code")%></td>
<td><%=rs("Description")%></td>
<td><%=rs("Total Charge")%></td>
</tr>
<% End If
rs.MoveNext
Loop %>

解决方案


abbyle...@hotmail.com wrote:

my page works fine if the db search finds at least one record that
satifies the query.
but if it does not find a match I get the following error message.

Error Type:
ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

What do I need to change here to make this just display the page with
no data?

sSQL = "SELECT [Billing Date], [Service Number], [Subscriber User
Name]," & _
" Fund, Account,[Activity Code], Description, [Total Charge]" & _
" FROM 06_Statements" & _
" WHERE [Billing Date] = ''" & Request.Form("cmonth") & "''" & _
" AND [Service Number] = ''" & Request.Form("cnumb") & "''" & _
" AND cstr([Total Charge]) = ''" & cstr(Request.Form("camount")) & "''"
set rs = Connect.Execute(sSQL)

<%
Do until rs.eof
%>
<tr>
<td><%=rs("Service Number")%></td>
<td><%=rs("Subscriber User Name")%></td>
<td><%=rs("Fund")%></td>
<td><%=rs("Account")%></td>
<td><%=rs("Activity Code")%></td>
<td><%=rs("Description")%></td>
<td><%=rs("Total Charge")%></td>
</tr>
<% End If
rs.MoveNext
Loop %>



If not rs.eof then
Do until rs.eof
%>
<tr>
<td><%=rs("Service Number")%></td>
<td><%=rs("Subscriber User Name")%></td>
<td><%=rs("Fund")%></td>
<td><%=rs("Account")%></td>
<td><%=rs("Activity Code")%></td>
<td><%=rs("Description")%></td>
<td><%=rs("Total Charge")%></td>
</tr>
<% End If
rs.MoveNext
Loop
Else
response.write "No records to show"
End If
%>

/P.



Paxton wrote:

abbyle...@hotmail.com wrote:

my page works fine if the db search finds at least one record that
satifies the query.
but if it does not find a match I get the following error message.

Error Type:
ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

What do I need to change here to make this just display the page with
no data?

sSQL = "SELECT [Billing Date], [Service Number], [Subscriber User
Name]," & _
" Fund, Account,[Activity Code], Description, [Total Charge]" & _
" FROM 06_Statements" & _
" WHERE [Billing Date] = ''" & Request.Form("cmonth") & "''" & _
" AND [Service Number] = ''" & Request.Form("cnumb") & "''" & _
" AND cstr([Total Charge]) = ''" & cstr(Request.Form("camount")) & "''"
set rs = Connect.Execute(sSQL)

<%
Do until rs.eof
%>
<tr>
<td><%=rs("Service Number")%></td>
<td><%=rs("Subscriber User Name")%></td>
<td><%=rs("Fund")%></td>
<td><%=rs("Account")%></td>
<td><%=rs("Activity Code")%></td>
<td><%=rs("Description")%></td>
<td><%=rs("Total Charge")%></td>
</tr>
<% End If
rs.MoveNext
Loop %>



If not rs.eof then
Do until rs.eof
%>
<tr>
<td><%=rs("Service Number")%></td>
<td><%=rs("Subscriber User Name")%></td>
<td><%=rs("Fund")%></td>
<td><%=rs("Account")%></td>
<td><%=rs("Activity Code")%></td>
<td><%=rs("Description")%></td>
<td><%=rs("Total Charge")%></td>
</tr>
<% End If
rs.MoveNext
Loop
Else
response.write "No records to show"
End If
%>

/P.



Oops. I didn''t spot an odd ''End If'' already in your code - just before
rs.movenext. You need to remove that - it serves no purpose that I can
see in the snippet.

/P.


that didn''t work even after I removed my "End If"
I got the error:
Error Type:
Microsoft VBScript compilation (0x800A040E)
''loop'' without ''do''


这篇关于数据库搜索什么都找不到的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆