Skip to content
Benjamin edited this page Jan 7, 2022 · 3 revisions

ADODB

Various access methods are typically employed to access ADODB record sets. While an ORM may alleviate some of this problem by not having to convert direct database access, a simple extension method should suffice to remote most of the pain associated with them.

Field Access

Field Accessor: RS("FieldName")

By using a simple extension method, you can convert these fairly painlessly:

    public static dynamic Field(this ADODB.Recordset R, String fName)
    {
        return R.Fields[fName].Value;
    }

The above field reference typically would have to be converted as such: RS("FieldName") becomes RS.Fields["FieldName"].Value.

Using the above extension method to the ADODB Recordset object, you can do one edit: RS.Field("FieldName")

Dictionary Access Operator: RS!FieldName

While not as easy as converting the other syntax, the dictionary access operator can likewise be converted to RS.Field("FieldName"), but not in a single-operation-per-instance manner, as with above.

Consider changing the dictionary access operator to the field accessor pattern in the linting stage since they are interchangeable, and the ! syntax does not have any representation in other languages.

Remarks

While still a manual change to many places, a good RegEx based search/replace should suffice for this for variables using direct Record Set Access.

The simplest way to do this en-masse, without typing and without a search/replace filter, would be to pre-load your clipboard with .Field, and then click before the opening parenthesis ((), and simply type Ctrl-V. Then click in the next location and Ctrl-V. The process is smooth and goes relatively quickly.