title: Error saving data from textbox to sql server table
body: <p>I have created a WPF desktop application before and I was able to write up the code to save data from a textbox to a table I created in sql server 2012. I tried to create a WPF Web browser application and the same code was not working to save my data to my sql database. I am now trying to create another WPF desktop application and the same code that worked the last time is not working anymore. Please look at my code and help.</p>
  
  <pre><code>private void savebuyers_Click(object sender, RoutedEventArgs e)
  {
          string connectionstring = null;
          connectionstring = "Data Source=FRANCIS;Initial Catalog=Pam Golding;Integrated Security=SSPI";
          SqlConnection con = new SqlConnection(connectionstring);
  
          try
          {
              string query;
              query = "insert into buyers (name,number,email) values ('" + namebuyers.Text + "'," + Convert.ToInt32(numberbuyers) + ",'" + emailbuyers.Text + "')";
              SqlCommand command = new SqlCommand(query, con);
              message1.Text = "Data Saved Successfully!";
              con.Open();
              command.ExecuteNonQuery();
              con.Close();
          }
          catch
          {
              message1.Text = "Error While Saving Data!";
          }
  }
  </code></pre>