记录集 .value 属性 [英] Recordset .value property

查看:31
本文介绍了记录集 .value 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅下面的 DDL:

Please see the DDL below:

CREATE TABLE TestDate (bookingdate datetime)
INSERT INTO TestDate VALUES ('2013-10-04')

请参阅下面的 ADODB 记录集:

Please see the ADODB recordset below:

rs.open "SELECT bookingdate FROM TestDate"
If rs("bookingdate") > dateadd("yyyy", -6, Now)
  msgbox("test")
end if

指定rs("bookingdate")rs("bookingdate").value 有什么区别.我在这里阅读了一些问题,回答者说总是使用 .value,但没有解释原因.我在 MSDN 上看过,但找不到答案.

What is the difference between specifying rs("bookingdate") and rs("bookingdate").value. I have read some questions on here where answerers say always use .value, but it is not explained why. I had a look on MSDN but could not find an answer.

推荐答案

Value默认属性<Field 对象的/a>,所以在 VB6 中 rs("bookingdate")rs("bookingdate").value 之间没有区别code> 在没有 Set 的情况下使用时.

Value is the default property of the Field object, so in VB6 there is no difference between rs("bookingdate") and rs("bookingdate").value when used without Set.

我个人不喜欢使用不带参数的默认属性.它使代码减少混乱 IMO.

I personally prefer not using default properties that don't take parameters. It makes the code less confusing IMO.

在VB.NET中默认属性必须有参数,所以不会出现这种情况.
注意 Recordset 有这样一个带参数的默认属性,你用它来返回 Field 对象:rs("bookingdate") 实际上是 <代码>rs.Item("bookingdate").使用这些,IMO,没有害处.

In VB.NET the default property must have a parameter, so this situation does not occur.
Note Recordset has such default property with parameter, and you are using it to return the Field object: rs("bookingdate") is actually rs.Item("bookingdate"). Using those, IMO, makes no harm.

这篇关于记录集 .value 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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