“If not rs.EOF”的非常奇怪的行为,需要帮助...... [英] Very strange behavior of "If Not rs.EOF", Need help...

查看:60
本文介绍了“If not rs.EOF”的非常奇怪的行为,需要帮助......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解这一点!


我有以下代码:


<%

....连接数据库的代码......

....检索记录集的代码...


如果不是rs.EOF那么

...做点什么...

结束如果

%>


非常基本。非常简单。除了条件是

在我运行脚本时完全被忽略的事实! < _<


那是对的......我故意在我的SQL中输入一个不存在的值

查询:


<%

sql =" Select * From user_database Where username =''non-existant-name''"

rs.Open sql,conn


如果不是rs.EOF那么

......做点什么...

结束如果

%>


在这种情况下,rs.EOF应该设置为true,因为我输入的用户名
不存在!因此,没有rs.EOF的条件不符合
,并且条件内的代码不应该运行,但是对于

它运行的一些奇怪的原因...所以这里发生了什么?!


我注意到如果我用不同的方式写它,它确实有点像它的b $ b应该是:


<%

如果rs.EOF则

Response.Write("记录不存在。< br / >")

Else

...做点什么...

结束如果

%> ;


然而它也应该以其他方式工作,所以这很奇怪

至少可以说!有没有人知道这里发生了什么?

我的代码有问题吗?因为我注意到当我使用''Else''子句时它确实有用......但是从什么时候开始就有问题

写一个条件没有''其他''条款?


谢谢!

I can''t get my head around this!

I have the following code:

<%
.... Code for connection to the database ...
.... Code for retrieving recordset ...

If Not rs.EOF Then
... Do something...
End If
%>

Very basic. Very simple. Except for the fact the the conditional is
completely ignored when I run the script!! <_<

That''s right... I deliberately enter a non existant value in my SQL
query:

<%
sql = "Select * From user_database Where username=''non-existant-name''"
rs.Open sql, conn

If Not rs.EOF Then
... Do something...
End If
%>

In this case rs.EOF should be set to true, since the username that I
entered does not exist! Therefor the condition of Not rs.EOF is not
met, and the code inside the conditional should not run, however for
some strange reason it does run... so what''s going on here?!

I noticed that if I write it differently it does work like it''s
supposed to:

<%
If rs.EOF Then
Response.Write("The record does not exist.<br />")
Else
... Do Something ...
End If
%>

However it should work the other way too, so this is very strange to
say the least! Does anybody have any idea as to what is going on here?
Is there something wrong with my code? Because I noticed that when I
use the ''Else'' clause it does work... but since when is it a problem
writing a conditional without an ''Else'' clause?

Thanks!

推荐答案

我总是使用......


with rs

如果不是(.bof和.eof)那么

文章< 11 ***** ****************@b28g2000cwb.googlegroups。 com>,
qu********@gmail.com 说......
i always use...

with rs
if not(.bof and .eof) then
In article <11*********************@b28g2000cwb.googlegroups. com>,
qu********@gmail.com says...

>
我无法理解这一点!

我有以下代码:

<%
...连接数据库的代码......
...检索记录集的代码......

如果不是rs。 EOF然后

...做点什么...
结束如果
%>

非常基本。非常简单。除了在运行脚本时条件被完全忽略的事实! < _<

那是对的...我故意在我的SQL查询中输入一个不存在的值:

<%
sql =" Select * From user_database Where username =''non-existant-name''"
rs.Open sql,conn

如果不是rs.EOF那么

......做点什么......
结束如果
%>

在这种情况下,rs.EOF应该设置为true,因为用户名是我输入不存在!因此,不符合rs rs.EOF的条件,并且条件内的代码不应该运行,但是对于
一些奇怪的原因它确实运行...那么这里发生了什么? !

我注意到,如果我用不同的方式写它,它的工作原理就像它应该的那样:

<%
如果rs。 EOF然后

Response.Write(记录不存在。< br />"
否则

...做点什么。 ..
结束如果
%>

然而它也应该以其他方式工作,所以这是非常奇怪的
至少说!有没有人知道这里发生了什么?
我的代码有什么问题吗?因为我注意到当我使用''Else''条款时它确实有用......但是从什么时候开始出现问题
写一个没有''Else''条款的条件?

谢谢!
>
I can''t get my head around this!

I have the following code:

<%
... Code for connection to the database ...
... Code for retrieving recordset ...

If Not rs.EOF Then
... Do something...
End If
%>

Very basic. Very simple. Except for the fact the the conditional is
completely ignored when I run the script!! <_<

That''s right... I deliberately enter a non existant value in my SQL
query:

<%
sql = "Select * From user_database Where username=''non-existant-name''"
rs.Open sql, conn

If Not rs.EOF Then
... Do something...
End If
%>

In this case rs.EOF should be set to true, since the username that I
entered does not exist! Therefor the condition of Not rs.EOF is not
met, and the code inside the conditional should not run, however for
some strange reason it does run... so what''s going on here?!

I noticed that if I write it differently it does work like it''s
supposed to:

<%
If rs.EOF Then
Response.Write("The record does not exist.<br />")
Else
... Do Something ...
End If
%>

However it should work the other way too, so this is very strange to
say the least! Does anybody have any idea as to what is going on here?
Is there something wrong with my code? Because I noticed that when I
use the ''Else'' clause it does work... but since when is it a problem
writing a conditional without an ''Else'' clause?

Thanks!


所以你在浪费击键。这与用户的问题有什么关系?


fantum写道:
So you''re wasting keystrokes. how is that relevant to the user''s problem?

fantum wrote:

i总是使用...


带rs

如果不是(.bof和.eof)那么


文章< 11 *** ******************@b28g2000cwb.googlegroups。 com>,
qu********@gmail.com 说......
i always use...

with rs
if not(.bof and .eof) then
In article <11*********************@b28g2000cwb.googlegroups. com>,
qu********@gmail.com says...

>>
我无法理解这个问题!

我有以下代码:

<%
...连接数据库的代码......
...检索记录集的代码...

如果不是rs.EOF然后
......做点什么...
结束如果
%>

非常基本。非常简单。除了在运行脚本时条件被完全忽略的事实! < _<

那是对的...我故意在我的SQL查询中输入一个不存在的值:

<%
sql =" Select * From user_database Where
username =''non-existant-name''" rs.Open sql,conn

如果没有rs.EOF那么
......做点什么...
结束如果
%>

在这种情况下,rs.EOF应该设置为true,因为我输入的用户名不存在!因此,不符合rs rs.EOF的条件,并且条件内的代码不应该运行,但是对于
一些奇怪的原因它确实运行...那么这里发生了什么? !

我注意到,如果我用不同的方式写它,它的工作原理就像它应该的那样:

<%
如果rs。 EOF然后
Response.Write(记录不存在。< br />)
其他
......做点什么......
结束如果
%>

然而它也应该以其他方式工作,所以这至少可以说是非常奇怪的!有没有人知道这里发生了什么?我的代码有问题吗?因为我注意到
当我使用''Else''子句时它确实有用......但是因为什么时候写一个没有''Else''条款的条件的问题?

谢谢!
>>
I can''t get my head around this!

I have the following code:

<%
... Code for connection to the database ...
... Code for retrieving recordset ...

If Not rs.EOF Then
... Do something...
End If
%>

Very basic. Very simple. Except for the fact the the conditional is
completely ignored when I run the script!! <_<

That''s right... I deliberately enter a non existant value in my SQL
query:

<%
sql = "Select * From user_database Where
username=''non-existant-name''" rs.Open sql, conn

If Not rs.EOF Then
... Do something...
End If
%>

In this case rs.EOF should be set to true, since the username that I
entered does not exist! Therefor the condition of Not rs.EOF is not
met, and the code inside the conditional should not run, however for
some strange reason it does run... so what''s going on here?!

I noticed that if I write it differently it does work like it''s
supposed to:

<%
If rs.EOF Then
Response.Write("The record does not exist.<br />")
Else
... Do Something ...
End If
%>

However it should work the other way too, so this is very strange to
say the least! Does anybody have any idea as to what is going on
here? Is there something wrong with my code? Because I noticed that
when I use the ''Else'' clause it does work... but since when is it a
problem writing a conditional without an ''Else'' clause?

Thanks!



-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果您必须离线回复,请删除

NO SPAM

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"


John写道:
John wrote:

我无法理解这个!


我有以下代码:


< ;%

...连接数据库的代码......

...检索记录集的代码...


如果没有rs.EOF那么

...做点什么...

结束如果

%>


非常基本。非常简单。除了条件是

在我运行脚本时完全被忽略的事实! < _<


那是对的......我故意在我的SQL中输入一个不存在的值

查询:


<%

sql =" Select * From user_database Where username =''non-existant-name''"

rs.Open sql,conn


如果不是rs.EOF那么

......做点什么...

结束如果

%>


在这种情况下,rs.EOF应该设置为true,因为我输入的用户名
不存在!因此,没有rs.EOF的条件不符合
,并且条件内的代码不应该运行,但是对于

它运行的一些奇怪的原因...所以这里发生了什么?!


我注意到如果我用不同的方式写它,它确实有点像它的b $ b应该是:


<%

如果rs.EOF则

Response.Write("记录不存在。< br / >")

Else

...做点什么...

结束如果

%> ;


然而它也应该以其他方式工作,所以这很奇怪

至少可以说!有没有人知道这里发生了什么?

我的代码有问题吗?因为我注意到当我使用''Else''子句时它确实有用......但是从什么时候开始就有问题

写一个条件没有'' Else''条款?
I can''t get my head around this!

I have the following code:

<%
... Code for connection to the database ...
... Code for retrieving recordset ...

If Not rs.EOF Then
... Do something...
End If
%>

Very basic. Very simple. Except for the fact the the conditional is
completely ignored when I run the script!! <_<

That''s right... I deliberately enter a non existant value in my SQL
query:

<%
sql = "Select * From user_database Where username=''non-existant-name''"
rs.Open sql, conn

If Not rs.EOF Then
... Do something...
End If
%>

In this case rs.EOF should be set to true, since the username that I
entered does not exist! Therefor the condition of Not rs.EOF is not
met, and the code inside the conditional should not run, however for
some strange reason it does run... so what''s going on here?!

I noticed that if I write it differently it does work like it''s
supposed to:

<%
If rs.EOF Then
Response.Write("The record does not exist.<br />")
Else
... Do Something ...
End If
%>

However it should work the other way too, so this is very strange to
say the least! Does anybody have any idea as to what is going on here?
Is there something wrong with my code? Because I noticed that when I
use the ''Else'' clause it does work... but since when is it a problem
writing a conditional without an ''Else'' clause?



这对我来说也很令人费解。你可以使用pubs或

Northwind数据库来举例说明我们可以自己试试代码吗?我怀疑可能会在你剪掉的东西中找到根

因素:


<%

....代码用于连接数据库...

....检索记录集的代码...


给我们一个更完整的例子,这样我们就可以看到我们自己的行为。

-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果您必须离线回复,请删除

无垃圾邮件

It''s puzzling to me as well. Could you whip up an example using the pubs or
Northwind database so we could try the code ourselves? I suspect the root
cause may be found in the stuff you snipped:

<%
.... Code for connection to the database ...
.... Code for retrieving recordset ...

Give us a more complete example so we can see the behavior for ourselves.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"


这篇关于“If not rs.EOF”的非常奇怪的行为,需要帮助......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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