In an attempt to refactor some of my code, I've added a function to setup an OleDbDataReader.
The return value that I'm getting is for some odd reason a System.Data.Common.DbDataRecord.
Just prior to the function returning the object, I checked to see that it is indeed a DataReader.
Here's the function's code:
function Execute-Reader { param($conObj = $(throw "conObj parameter required"), $sqlStr = $(throw "sqlStr parameter required"))
$cmd = New-Object system.data.oledb.oledbcommand
$cmd.connection = $conObj
$cmd.commandtext = $sqlStr
$reader = $cmd.executereader()
return [System.Data.OleDb.OleDbDataReader]$reader
}
and being called with the following
$reader = Execute-Reader $conObj $query
There's no exceptions. The only problem is with the $reader being the incorrect type. Somehow casted, or something.