title: PowerShell MySQL query syntax
body: <p>I want to insert data into my MySQL database using PowerShell.</p>
  
  <p>My code is working, but I have a little problem with the variables in the insert string.</p>
  
  <p>How can I use a variable in the insert string?</p>
  
  <pre><code>[system.reflection.assembly]::LoadWithPartialName("MySql.Data")
  $cn = New-Object -TypeName MySql.Data.MySqlClient.MySqlConnection
  $cn.ConnectionString = "SERVER=localhost;DATABASE=test;UID=root;PWD=pwd"
  $cn.Open()
  $cm = New-Object -TypeName MySql.Data.MySqlClient.MySqlCommand
  
  
  #The problem, not working
  $n = 7
  $sql = 'INSERT INTO db1ea4test1.besitzer (besID, Vorname, Name) VALUES ( '$n' , "Testvor" + '$n' , "Testnach" + '$n')'
  
  # Working
  #$sql = 'INSERT INTO db1ea4test1.besitzer (besID, Vorname, Name) VALUES ("6", "Testvor", "Testnach")'
  
  
  $cm.Connection = $cn
  $cm.CommandText = $sql
  $dr = $cm.ExecuteNonQuery()
  </code></pre>