The following PowerShell code loads the SQL result into a dataset:
$sqlCommand = "SELECT A, B FROM TestTable"
$connection = New-Object System.Data.OleDb.OleDbConnection $connectionString
$command = New-Object System.Data.OleDb.OleDbCommand $sqlCommand,$connection
$connection.Open()
$adapter = New-Object System.Data.OleDb.OleDbDataAdapter $command
$dataset = New-Object System.Data.DataSet
[void] $adapter.Fill($dataSet)
I am surprised to learn that $ dataset.Tables [0] .Rows [0] .A works! I tried translating the string to Get-Member, and indeed A and B are indicated as properties of the object. Does anyone know why this works? DataSet was not created from XSD. I tried to write the same lines of code in C # and use a debugger, I do not see properties A and B.
Jack
source
share