title: Data not saving permanently to SQL table
body: <p>I am using C# for a WPF application in Visual Studio Express 2012.  I followed the tutorial found <a href="https://www.youtube.com/watch?v=HwA-tNvU3hw" rel="nofollow">here</a>.
  I created a <code>testDb.mdf</code> local Service-based database.  I open the application, enter text, hit add, and the data adds to the db.  I only know this because I have the one field setup as a primary key and unique.  If I try to add the same thing again I get an error saying it already exists.</p>
  
  <p>When I exit my application nothing shows in the database.  The data I entered is gone.  Why is the data not permanent?</p>
  
  <p>Here is the code I'm using for my button click:</p>
  
  <pre><code>private void Add_Click(object sender, RoutedEventArgs e)
  {
      SqlConnection cn = new SqlConnection(global::testdb.Properties.Settings.Default.testDBConnectionString);
      try 
      { 
          string sql = "INSERT INTO Test (TestInsert) Values('" + txtName.Text + "')";
          SqlCommand cmd = new SqlCommand(sql, cn);
          cn.Open();
          cmd.ExecuteNonQuery();
  
          MessageBox.Show("Added new record", "Message", MessageBoxButton.OK);
      }
      catch (Exception ex) 
      {
          MessageBox.Show(ex.Message,"Error", MessageBoxButton.OK);
      }
      finally
      {
          cn.Close();
      }
  }
  </code></pre>
  
  <p>Connection String:</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="testdb.Properties.Settings.testDBConnectionString"
          connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\testDB.mdf;Integrated Security=True"
          providerName="System.Data.SqlClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>