Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15260

VS 2012 What to hijack a SqlDataReader class so it can be sourced from multiple places

$
0
0
Ok - I'm using a simple SqlDataReader like this:

Code:

Using rsPrint As SqlDataReader = cmd.ExecuteReader

    ReDim strRS(0 To rsPrint.FieldCount - 1, 0 To 2)

    If Not rsPrint.HasRows Then
.
.
.
        If rsPrint.HasRows Then
            If rsPrint.GetName(0) = "%%errormessage%%" Then
                strErrorMessage = rsPrint(0)
                Exit Do
            End If
        End If

Simple stuff - using for example: .FieidlCount, .HasRows, .GetName and more important, the default method which just returns a field (rsPrint(0) near the bottom of that code snippet).

What I'm looking to do is allow for this existing SQL access - calling that ExecuteReader at the top to work but also allow the "source" of the data to be a local array.

I'm thinking I can "override" each method and property to either "call the underlying" SqlDataReader code, or "use" my own code that is managing the local array instead.

I'm looking to not change any of the code in this Using Block - basically transparently source rsPrint from two different places.

I know how to do this in JavaScript - and believe I've seen it done here before.

I'm using VS 2012 unfortunately.

TIA! Steve

Viewing all articles
Browse latest Browse all 15260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>