Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requieres MySQL Connector NET 8.3.0 and SimplySql Powershell Module
- [void][system.reflection.Assembly]::LoadFrom("C:\Program Files (x86)\MySQL\MySQL Connector NET 8.3.0\MySql.Data.dll")
- $Mysqlhost= "localhost"
- $Mysqluser= "root"
- $Mysqlpass= "myrootpswd"
- $Mysqldatabase= "mydb"
- $Connection = [MySql.Data.MySqlClient.MySqlConnection]@{ConnectionString="server=$Mysqlhost;uid=$Mysqluser;pwd=$Mysqlpass;database=$Mysqldatabase"}
- $Connection.Open()
- $sql = New-Object MySql.Data.MySqlClient.MySqlCommand
- $sql.Connection = $Connection
- $sql.CommandText = "SELECT title FROM recipes"
- $myreader = $sql.ExecuteReader()
- while($myreader.Read()) {
- $myreader.GetString(0)
- }
- $myreader.Close()
- $sql.CommandText = "SELECT full_name FROM users"
- $myreader = $sql.ExecuteReader()
- while($myreader.Read()) {
- $myreader.GetString(0)
- }
- $myreader.Close()
- $Connection.Close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement