What does rs.Fields (0) mean? (ADODB) VBA

dim rs As ADODB.Recordset
...
...
...
capture_id = rs.Fields(0)

      

which means. Are the fields (0) mean?

+2


a source to share


3 answers


the first column from the recordset (0) is the first (1) - the second, etc. etc.

For example, if this is your request



select LastName, FirstName 
from YourTable

      

In this case s.Fields (0) will return the LastName column and rs.Fields (1) will return the FirstName column

+5


a source


It pulls the first column from the current row in the result set.

Fields(x)

allows you to access fields using a numeric index starting at 0.

Edit

Example:



If the result set has two columns: foo

and bar

..

rs.Fields(0)

will return the column value foo

,

and

rs.Fields(1)

will return the column value bar

.

+3


a source


I would never, ever use this syntax. It depends on the query always with the same field in the first position.

Moreover, it will only save a minute amount of time. (As in milliseconds, if not less.)

Please, for love of God, for correct programming practice, change this to use the field name. It almost, but not quite, belongs to the www.dailywtf.com website.

+1


a source







All Articles