Ok, I forget. Which is the faster or better way of getting a value from a recordset?
rs!FieldName or rs.Fields("FieldName")
Printable View
Ok, I forget. Which is the faster or better way of getting a value from a recordset?
rs!FieldName or rs.Fields("FieldName")
Allegedly, it's supposed to be the ! format, but I don't see how or why, and it always makes me nervous. I usualy opt for the .FIelds() route.
TG
I always use the ! method. I think it more a matter of what you are comfortable with.
I heard that the .Fields was faster performing
so I changed over to using it that way.
I prefer rst("field name")...
As to the speed - no idea, should be negligable anyway.
If it is a major speed difference, please post up so I can change :)
Vince
I always use rs.fields("fieldname"). Like Vince says, I'm sure any difference will be undetectable. Unless anyone knows different!
I think I ran into problems when using ! in the past - for example if a field name contained unusual characters, this caused the VB IDE a bit of grief. Obviously a well designed database shouldn't use weird character sets for field names, but I was linking to a third party database, and didn't have any control over it.
Another possible reason to stick to .Fields("name") is to future proof your code - I think the .NET code conversion utility ignores !, (at least it did in the early versions, MS might have addressed this now).
George
MS Told me that using ordinals is faster.
objrs.Fields(0).Value > objrs.Fields("fieldname") > objrs!fieldname