title: Data not saved in SQL Server database after rerun c#
body: <p>I've finally got my connection string working. Now I have written some code to insert into a table called <code>Customers</code> in the <code>Database.mdf</code>. When I click the "registreer" button in the form I insert the name in the usernameTF2 into the table and after that I call the <code>ShowCustomers</code> method to reload the listbox.. </p>
  
  <p>When I rerun the program, it still shows the previous made names in the listbox, but still doesn't show the names in the server explorer.</p>
  
  <p>Code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Configuration;
  using System.ComponentModel;
  using System.Data;
  using System.Data.SqlClient;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  using ProductClient.ProductService;
  using TestDB;
  using System.Configuration;
  using System.Data.SqlClient;
  
  namespace WindowsFormsApplication1
  {
      public partial class Form1 : Form
      {
          ProductServiceClient productProxy = new ProductServiceClient();
  
          SqlConnection connection; 
          string connectionString;
  
          public Form1()
          {
              InitializeComponent();
              connectionString = ConfigurationManager.ConnectionStrings["TestDB.Properties.Settings.DatabaseConnectionString"].ConnectionString;
              ShowCustomers();
          }
  
          private void ShowCustomers()
          {
              using (connection = new SqlConnection(connectionString))
              using (SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Customer", connection))
              {
                  DataTable productTable2 = new DataTable();
                  adapter.Fill(productTable2);
  
                  lstBox.DisplayMember = "Name";
                  lstBox.ValueMember = "Id";
                  lstBox.DataSource = productTable2;
              }
          }
  
          private void registreerBTN_Click(object sender, EventArgs e)
          {
              string response = productProxy.Register(usernameTF2.Text);
              wachtwoordLAB.Text = response;
  
              string query = "INSERT INTO Customer VALUES(@Name, 20)"; ////
  
              using (connection = new SqlConnection(connectionString))////
              using (SqlCommand command = new SqlCommand(query, connection))////
              {
                  connection.Open();
                  command.Parameters.AddWithValue("@Name",usernameTF2.Text);////
                  command.ExecuteNonQuery();
                  MessageBox.Show("Added");
                  connection.Close();
              }
  
              ShowCustomers();
          }
      }
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/TXXkJ.png" alt="enter image description here"></p>
  
  <p>The <code>Copy to Output Directory</code> is already set to <code>Copy if newer</code>.</p>
  
  <p>Connectionstring:</p>
  
  <p>In the form:    </p>
  
  <pre><code>connectionString = ConfigurationManager.ConnectionStrings["TestDB.Properties.Settings.DatabaseConnectionString"].ConnectionString;
  </code></pre>
  
  <p>In the app config:      </p>
  
  <pre><code>connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True"
  </code></pre>