title: Fill dataGrid from MySQL database in C# WPF
body: <p>I want to fill a dataGrid in my WPF application.</p>
  
  <p>My XAML:</p>
  
  <pre><code>&lt;DataGrid AutoGenerateColumns="True" Height="200" HorizontalAlignment="Left" 
  Margin="102,72,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="848" /&gt;
  </code></pre>
  
  <p>My code behind:</p>
  
  <pre><code>  public void FillGrid()
      {
          string MyConString =    
          "SERVER=myserver.com;" +
          "DATABASE=mydatabase;" +
          "UID=myuserid;" +
          "PASSWORD=mypass;";
  
          string sql = "SELECT clientnr, name, address FROM clients ORDER BY name";
  
          MySqlConnection connection = new MySqlConnection(MyConString);
          MySqlCommand cmdSel = new MySqlCommand(sql, connection);
          DataTable dt = new DataTable();
          MySqlDataAdapter da = new MySqlDataAdapter(cmdSel);
          da.Fill(dt);
          dataGrid1.DataContext = dt;
      }
  </code></pre>
  
  <p>I'm sure that the MySQL part is correct, it does not give any errors.
  VS10 express doesn't give any errors. But if i execute the method my dataGrid won't be filled.</p>
  
  <p>What I'm doing wrong?</p>
  
  <p>Thanks in advance!</p>