Posts Tagged: connection

MySQL connection with Powershell

Posted by & filed under , .

Here is the script that establishing a connection to the Mysql database with ‘select statement’ Param( [Parameter( Mandatory = $true, ParameterSetName = ”, ValueFromPipeline = $true)] [string]$Query ) $ConnectionString=”This is your connection string” Try { [void][System.Reflection.Assembly]::LoadWithPartialName(“MySql.Data”) $Con = New-Object MySql.Data.MySqlClient.MySqlConnection $Con.ConnectionString = $ConnectionString $Con.Open() $MySqlCommand= New-Object MySql.Data.MySqlClient.MySqlCommand($Query, $Con) $DataAdapter = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($MySqlCommand) $DataSet = New-Object […]