title: inserting data to database does not load straight away
body: <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Shapes;
  using System.Data.SqlClient;
  
  namespace SolutionCW
  {
      /// &lt;summary&gt;
      /// Interaction logic for addCustomer.xaml
      /// &lt;/summary&gt;
      public partial class addCustomer : Window
      {
          public addCustomer()
          {
              InitializeComponent();
          }
  
          private void Button_Click(object sender, RoutedEventArgs e) // add customer button
          {
              string inputName = nameinput.Text;
              string inputLastname = secondnameinput.Text;
              string Number = phonenumber.Text;
              string address = addressinput.Text;
              string Pcode = postcode.Text;
  
              string cmdstring = "INSERT INTO Customer (FirstName, LastName, PhoneNumber, Address, Postcode) VALUES (@Name, @LastName, @Phone, @Addinput, @Pcode)";
  
              string connString = MainWindow.DBconnection;
  
              using (SqlConnection conn = new SqlConnection(connString))
              {
                  using (SqlCommand comm = new SqlCommand())
                  {
                      comm.Connection = conn;
                      comm.CommandText = cmdstring;
  
                      comm.Parameters.AddWithValue("@Name", nameinput.Text);
                      comm.Parameters.AddWithValue("@LastName", secondnameinput.Text);
                      comm.Parameters.AddWithValue("@Phone", phonenumber.Text);
                      comm.Parameters.AddWithValue("@Addinput", addressinput.Text);
                      comm.Parameters.AddWithValue("@Pcode", postcode.Text);
  
                      try
                      {
                          conn.Open();
                          comm.ExecuteNonQuery();
                          conn.Close();
  
                          Customer basic = new Customer();
                          basic.updateTable();
                      }
                      catch(SqlException)
                      {
                      }
  
                      this.Close();
                  }
          }
      }
  }
  </code></pre>
  
  <p>I have shown my code for adding a customer record from the form to my database, but when I press the add button, it does not show the newly entered data when it opens up the database. It only shows the newly entered record when I exit the database/refresh and go back in? any help appreciated, thanks</p>