title: SQL Server connection in WPF
body: <p>I have a data base in SQL Server 2008 and connecting it in <code>WPF</code> application.I want to read data from table and show in <code>datagrid</code>. Connection is successfully created but when I show it in grid,it show db error(Exception handling).
  This is what I am doing.Thanks in advance.</p>
  
  <pre><code>  try
    {
         SqlConnection thisConnection = new SqlConnection(@"Server=(local);Database=Sample_db;Trusted_Connection=Yes;");
         thisConnection.Open();
  
         string Get_Data = "SELECT * FROM emp";     
  
         SqlCommand cmd = new SqlCommand(Get_Data);              
         SqlDataAdapter sda = new SqlDataAdapter(cmd);               
         DataTable dt = new DataTable("emp");
         sda.Fill(dt);
         MessageBox.Show("connected");
         //dataGrid1.ItemsSource = dt.DefaultView;           
    }
    catch
    {
         MessageBox.Show("db error");
    }
  </code></pre>
  
  <p>It shows <code>connected</code> when i comment the line  <code>sda.Fill(dt);</code></p>