测试空记录集的最佳方法是什么? [英] best way to test for an empty recordset?

查看:83
本文介绍了测试空记录集的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rst.eof = true而rst.bof = true




rst.movelast

rst.recordcount = 0


rst.eof = true and rst.bof = true

or

rst.movelast
rst.recordcount = 0

?

推荐答案

如果没有记录,MoveLast将失败。


在DAO中,您可以使用RecordCount。如果有
记录,则至少为1;如果没有,则为0。


在ADO中,RecordCount可能为-1(未定义? ),取决于

记录集的种类。


无论哪种方式你应该没问题:

如果rst.BOF和rst.EOF然后


(注意BOF和EOF是真/假值,所以你不需要比较

它们是真的得到一个真/假的结果。)


-

Allen Browne - 微软MVP。西澳大利亚州珀斯。

访问用户提示 - http:// allenbrowne.com/tips.html

回复群组,而不是mvps dot org的allenbrowne。


" Mike MacSween" < MI ************************ @ btinternet.com>在消息中写道

news:41 ********************* @ news.aaisp.net.uk ...
The MoveLast will fail if there are no records.

In DAO, you can just use the RecordCount. It will be at least 1 if there are
records, and 0 if there are none.

In ADO, the RecordCount may be -1 (undefined?), depending on the kind of
recordset.

Either way you should be okay with:
If rst.BOF And rst.EOF Then

(Note that BOF and EOF are true/false values, so you don''t need to compare
them to True to get a true/false result.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mike MacSween" <mi************************@btinternet.com> wrote in message
news:41*********************@news.aaisp.net.uk...
rst.eof = true和rst.bof = true



rst.movelast
rst.recordcount = 0
rst.eof = true and rst.bof = true

or

rst.movelast
rst.recordcount = 0



" Allen Browne" <铝********* @ SeeSig.Invalid>在消息中写道

news:41 *********************** @ per-qv1-newsreader-01.iinet.net。 au ...
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:41***********************@per-qv1-newsreader-01.iinet.net.au...
如果没有记录,MoveLast将失败。


当然。傻我。

在DAO中,你可以使用RecordCount。如果
是记录,则至少为1;如果没有记录,则为0。

在ADO中,RecordCount可能为-1(未定义?),具体取决于<记录集。

无论哪种方式你应该没问题:
如果rst.BOF和rst.EOF那么

(注意BOF和EOF都是真的/ false值,所以你不需要将它们与True进行比较以获得真/假的结果。)
The MoveLast will fail if there are no records.
Of course. Silly me.
In DAO, you can just use the RecordCount. It will be at least 1 if there
are records, and 0 if there are none.

In ADO, the RecordCount may be -1 (undefined?), depending on the kind of
recordset.

Either way you should be okay with:
If rst.BOF And rst.EOF Then

(Note that BOF and EOF are true/false values, so you don''t need to compare
them to True to get a true/false result.)




当然。双傻我


谢谢Allen



Of course. Double silly me

Thanks Allen


嗨Chuck。


根据A2003帮助,在RecordCount属性(ADO)下:

使用RecordCount属性查找Recordset对象中有多少记录

。当ADO无法确定记录数或者提供者或游标类型

不支持RecordCount时,属性返回-1


我对该陈述的理解是RecordCount未确定,

所以我不确定我是否想要信任-1为某些。也许我是偏执狂。


-

Allen Browne - 微软MVP。西澳大利亚州珀斯。

访问用户提示 - http:// allenbrowne.com/tips.html

回复群组,而不是mvps dot org的allenbrowne。

" Chuck Grimsby" < C。******* @ worldnet.att.net.invalid>在消息中写道

新闻:kv ******************************** @ 4ax.com ...
Hi Chuck.

According to the A2003 help, under RecordCount Property (ADO):
Use the RecordCount property to find out how many records are
in a Recordset object. The property returns -1 when ADO cannot
determine the number of records or if the provider or cursor type
does not support RecordCount.

My understanding of that statement is that the RecordCount is undetermined,
so I''m not sure I want to trust -1 to be "some". Perhaps I''m paranoid.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Chuck Grimsby" <c.*******@worldnet.att.net.invalid> wrote in message
news:kv********************************@4ax.com...

-1 = true(是的,有记录,但不知道有多少)?
这就是我一直采取的方式它....

2004年11月29日星期一19:15:33 +0800,Allen Browne
< Al ********* @ SeeSig 。无效>写道:

-1 = true (Yes, there are records, but no idea how many yet)?
That''s the way I''ve always taken it....

On Mon, 29 Nov 2004 19:15:33 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
如果没有记录,MoveLast将失败。
在DAO中,您可以使用RecordCount。如果

记录,则至少为1;如果没有,则为0。
在ADO中,RecordCount可能为-1(未定义?),具体取决于<记录集。
无论哪种方式你应该没问题:
如果rst.BOF和rst.EOF然后
(注意BOF和EOF是真/假值,所以你不要'我们需要将它们与True进行比较才能获得真/假的结果。)
The MoveLast will fail if there are no records.
In DAO, you can just use the RecordCount. It will be at least 1 if there
are
records, and 0 if there are none.
In ADO, the RecordCount may be -1 (undefined?), depending on the kind of
recordset.
Either way you should be okay with:
If rst.BOF And rst.EOF Then
(Note that BOF and EOF are true/false values, so you don''t need to compare
them to True to get a true/false result.)



这篇关于测试空记录集的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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