测试空记录集的最佳方法是什么?

编程入门 行业动态 更新时间:2024-10-28 10:31:18
本文介绍了测试空记录集的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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/tips.html 回复群组,而不是mvps dot org的allenbrowne。 " Mike MacSween" < MI ************************ @ btinternet>在消息中写道 news:41 ********************* @ news.aaisp.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 - allenbrowne/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Mike MacSween" <mi************************@btinternet> wrote in message news:41*********************@news.aaisp.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。 au ... "Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:41***********************@per-qv1-newsreader-01.iinet.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/tips.html 回复群组,而不是mvps dot org的allenbrowne。 " Chuck Grimsby" < C。******* @ worldnet.att.invalid>在消息中写道 新闻:kv ******************************** @ 4ax ... 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 - allenbrowne/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Chuck Grimsby" <c.*******@worldnet.att.invalid> wrote in message news:kv********************************@4ax... -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 therearerecords, and 0 if there are none.In ADO, the RecordCount may be -1 (undefined?), depending on the kind ofrecordset.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 comparethem to True to get a true/false result.)

更多推荐

测试空记录集的最佳方法是什么?

本文发布于:2023-11-08 11:53:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569297.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:记录集   测试   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!