Good day everyone!
As always…I totally appreciate this subreddit. My salary has increased thanks to the information here.
I need help with something that I am sure is small:
I’m working on yet more powershell automation. In some of my recent posts I asked about working with DB2 and Microsoft Access through powershell. I received some great information that has helped me dramatically…
However…I am rewriting some other queries and need to return the actual dataset (I’ve previously only needed the rows returned to monitor some data). Can anyone give me a hint as to where I put an output command for the results returned from the query in this script? I’ve tried a number of things but can’t get a simple comma delimited CSV.
I see where the datatable is getting populated…but I’m a bit lost.
$connectstring = "DSN=XXXXXXXXX;Uid=XXXXXXX;Pwd=XXXXXXXX;" $sql = "my sql query;" $conn = New-Object System.Data.Odbc.OdbcConnection($connectstring) $cmd = New-Object system.Data.Odbc.OdbcCommand($sql,$conn) $da = New-Object system.Data.Odbc.OdbcDataAdapter($cmd) $dt = New-Object system.Data.datatable $da.SelectCommand = $cmd; $conn.Open(); $RowsReturned = $da.Fill($dt); $wshell = New-Object -ComObject Wscript.Shell $wshell.Popup("PreAudit DB2 returned $RowsReturned rows") #Write-Host $RowsReturned;
submitted by /u/mpellas
[link] [comments]
The post What small thing am I missing? appeared first on How to Code .NET.