Re: Reading data via field names vs ordinals

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Paul Clement (UseAdddressAtEndofMessage_at_swspectrum.com)
Date: 04/19/04


Date: Mon, 19 Apr 2004 09:24:58 -0500

On Mon, 19 Apr 2004 11:54:44 +0700, "tinman" <dwesar@yahoo.com> wrote:

¤ Hi...
¤
¤ Is it better to access the data via its ordinal or field name?
¤
¤ For example, is Option A or B the preferred way ? My concern here is what
¤ will
¤ happen if the resultset order changes?
¤
¤ Option A:
¤
¤ While ProjectData.Read
¤ m_ProjectName = ProjectData("proj_name")
¤ m_ProjectType = ProjectData("type")
¤ m_Reason = ProjectData("reason")
¤ End While
¤
¤
¤ Option B:
¤
¤ With ProjectData
¤ While .Read
¤ m_ProjectName = .Item("1")
¤ m_ProjectType = .Item("2")
¤ m_Reason = .Item("3")
¤ End While
¤ End With
¤

I would not trade-off the small performance enhancement when using ordinals for code readability.

Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)