MySQL rs.Fields(0) 是什么意思?(ADODB) VBA
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2829804/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what does rs.Fields(0) mean? (ADODB) VBA
提问by l--''''''---------''''''''''''
dim rs As ADODB.Recordset
...
...
...
capture_id = rs.Fields(0)
what does .Fields(0) mean?
.Fields(0) 是什么意思?
回答by SQLMenace
the first column from the recordset (0) is the first (1) is the second etc etc
记录集 (0) 中的第一列是第一列 (1) 是第二列等等
example, if this is your query
例如,如果这是您的查询
select LastName, FirstName
from YourTable
In this case s.Fields(0)would return column LastNameand rs.Fields(1)would return column FirstName
在这种情况下s.Fields(0)将返回列LastName和rs.Fields(1)将返回列FirstName
回答by Matt
It's pulling the first column from the current row in the result set.
它从结果集中的当前行中拉出第一列。
Fields(x)
lets you access fields by a numerical index starting at 0.
Fields(x)
允许您通过从 0 开始的数字索引访问字段。
Edit:
编辑:
Example:
例子:
If the result set has two columns: foo
and bar
..
如果结果集有两列:foo
和bar
..
rs.Fields(0)
would return the valueof column foo
,
rs.Fields(0)
将返回column的值foo
,
and
和
rs.Fields(1)
would return the valueof column bar
.
rs.Fields(1)
将返回column的值bar
。
回答by Tony Toews
I would NEVER, EVER use this syntax. This is dependant on the query alwayshaving the same field in the first position.
我永远不会使用这种语法。这取决于查询始终在第一个位置具有相同的字段。
Furthermore this would only save a minute amount of time. (As in milliseconds if not less.)
此外,这只会节省一分钟的时间。(如果不是更少的话,以毫秒为单位。)
Please, for the love of God, per proper programming practice, change that to use the field name. This almost, but not quite, belongs on the www.dailywtf.com website.
为了上帝的爱,请按照正确的编程实践将其更改为使用字段名称。这几乎但不完全属于 www.dailywtf.com 网站。