Erwin Pombett
asked on
with powershell i'm passing queries to sql in a loop. how can i cumulate what i'm receiving from sql (datatables) ?
hello,
in a loop i'm passing queries to sql. ok, i'm receiving the responses.
now i'm trying to group in a datatable all the respoinses i'm receiving which are datatables.
i've created the same datatable in order to be able to add to it but this is not working.
i need help.
$allmyResulst =
$allResults = New-Object System.Data.DataTable
$allResults.Columns.Add("P ersonID",[ System.Typ e]::GetTyp e("System. Int32"))
$allResults.Columns.Add("f irstname", [System.Ty pe]::GetTy pe("System .String"))
$allResults.Columns.Add("l astname",[ System.Typ e]::GetTyp e("System. String"))
foreach($aline in $allFileLines)
{
$query = "Select PersonID, firstname, lastname, email from table where firstname='lala'
$results = pass-queryagainstDBserver $theConnection $query
# ^ i receive my results ok
$allresults.rows.add($resu lts) <- this is not adding my new lines:
}
thank you in advance
in a loop i'm passing queries to sql. ok, i'm receiving the responses.
now i'm trying to group in a datatable all the respoinses i'm receiving which are datatables.
i've created the same datatable in order to be able to add to it but this is not working.
i need help.
$allmyResulst =
$allResults = New-Object System.Data.DataTable
$allResults.Columns.Add("P
$allResults.Columns.Add("f
$allResults.Columns.Add("l
foreach($aline in $allFileLines)
{
$query = "Select PersonID, firstname, lastname, email from table where firstname='lala'
$results = pass-queryagainstDBserver $theConnection $query
# ^ i receive my results ok
$allresults.rows.add($resu
}
thank you in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you for your reply,
indeed i had forgotten to add a column.
ok, indeed i could copy one Datarow from one Datatable to the other. Creating a new datarow works.
thank you.
Toshi