Hi, I am trying to get a script to work with the latest connector in windows and powershell 2. I seem to have a working script in powershell using the connector. (Example below.) and I can see my results in the powershell console and screen, but every way I try to export my results to csv or pipe to text I keep getting no data. It sounds like an easy fix but no luck so far. Any help or ideas appreciated. I tried piping export-csv and out-file combination and also calling the script as a function -- with no luck.
[void][system.reflection.Assembly]::LoadFrom("C:\Program Files\MySQL\MySQL Connector Net 6.5.4\Assemblies\v2.0\MySQL.Data.dll")
[void][System.Reflection.Assembly]::LoadWithPartialName("MySql.Data")
clear-host
$connect = New-Object MySql.Data.MySqlClient.MySqlConnection
$connect.ConnectionString = "server=$IP;uid=$USER;pwd=$PASS;database=$DB"
$connect.Open()
$command = New-Object MySql.Data.MySqlClient.MySqlCommand
$command.Connection = $connect
# $command.CommandText = "desc $TABLE"
$command.CommandText = "select COL1,COL2 from TABLE"
$reader = $command.executereader()
while($reader.Read()) {
$reader.GetString(0) + "," + $reader.GetString(1)
}
$connect.Close()
[void][system.reflection.Assembly]::LoadFrom("C:\Program Files\MySQL\MySQL Connector Net 6.5.4\Assemblies\v2.0\MySQL.Data.dll")
[void][System.Reflection.Assembly]::LoadWithPartialName("MySql.Data")
clear-host
$connect = New-Object MySql.Data.MySqlClient.MySqlConnection
$connect.ConnectionString = "server=$IP;uid=$USER;pwd=$PASS;database=$DB"
$connect.Open()
$command = New-Object MySql.Data.MySqlClient.MySqlCommand
$command.Connection = $connect
# $command.CommandText = "desc $TABLE"
$command.CommandText = "select COL1,COL2 from TABLE"
$reader = $command.executereader()
while($reader.Read()) {
$reader.GetString(0) + "," + $reader.GetString(1)
}
$connect.Close()