title: Not able to insert data into SQL Server through Windows Forms C#
body: <p>Compiler is not showing any error. I wonder whats the problem in it.</p>
  
  <p>And yes its also not showing message "Inserted !!"</p>
  
  <p>This is my first data inserting in Winforms. Yes I am new. </p>
  
  <p>Code:</p>
  
  <pre><code>public partial class Phone : Form
  {
      SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=phonemo;Persist Security Info=True;User ID=sa;Password=***********");
  
      public Phone()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          DialogResult dialogResult = MessageBox.Show("This will Clear Text", "New", MessageBoxButtons.YesNo);
  
          if (dialogResult == DialogResult.Yes)
          {
              //do something
          }
          else if (dialogResult == DialogResult.No)
          {
              //do something else
          }
  
          textBox1.Text = "";
          textBox2.Clear();
          textBox3.Text = "";
          textBox4.Clear();
          comboBox1.SelectedIndex = -1;
          textBox1.Focus();
  
          con.Open();
          String query = "INSERT INTO phonemoo (Fname,Sname,Mobile,Email,Catagory) VALUES ('"+ textBox1.Text +"','"+ textBox2.Text +"','"+ textBox3.Text +"','"+ textBox4.Text +"','"+ comboBox1.Text + "')";
  
          SqlDataAdapter sda = new SqlDataAdapter(query,con);
          sda.SelectCommand.ExecuteNonQuery();
  
          con.Close();
  
          MessageBox.Show("Inserted !!");
      }
  }
  </code></pre>
  
  <p>Thanks</p>