Created
July 9, 2014 22:32
-
-
Save jdmonty/82320d51dcf34c1210e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Executes an IDbCommand and converts the resultset | |
# to a Powershell object collection | |
function ExecuteCommand( | |
$command = { throw 'Command must be supplied' } | |
){ | |
$rows = @(); | |
$reader = $command.executereader() | |
while($reader.read()){ | |
$values = new-object object; | |
for($i = 0; $i -lt $reader.FieldCount; $i++){ | |
$name = $reader.GetName($i); | |
$value = $reader.GetValue($i); | |
Add-Member -in $values noteproperty $name $value | |
} | |
$rows+= $values; | |
} | |
$reader.Close(); | |
$rows | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From Nice Cup(Of T)