title: How to show a error message if the data is already inserted in the database in c#
body: <pre><code>protected void Button2_Click(object sender, EventArgs e)
  {
      SqlConnection conn = new SqlConnection("Data Source=KING;Initial Catalog=semasinter;Integrated Security=True");
      SqlCommand command = new SqlCommand("insert into StudentApplication", conn);
      command.CommandType = CommandType.StoredProcedure;
      command.CommandText = "spinsertstudentapplication";
      command.Parameters.AddWithValue("@Student_id", TextBox1.Text); 
      //command.Parameters.AddWithValue ("@Select_Course", ddlCourse.SelectedValue);
      command.Parameters.AddWithValue("@Select_Country", TextBox4.Text);
      command.Parameters.AddWithValue("@Select_State", TextBox2.Text);
      command.Parameters.AddWithValue("@Select_Franchise", TextBox3.Text);
      command.Parameters.AddWithValue("@Select_Sensei", ddlSensei.SelectedValue);
      command.Parameters.AddWithValue("@Group", TextBox6.Text);
      command.Parameters.AddWithValue("@Enter_Student_Name", TextBox7.Text);
      command.Parameters.AddWithValue("@Enter_Student_Address", TextBox8.Text);
      command.Parameters.AddWithValue("@Students_Father_Name", TextBox9.Text);
      command.Parameters.AddWithValue("@Student_DOB", TextBox10.Text);
      if (RadioButton2.Checked == true)
      {
          command.Parameters.Add("@Gender", SqlDbType.Bit).Value = true;
  
      }
      else
      {
          command.Parameters.Add("@Gender", SqlDbType.Bit).Value = false;
  
      }
      command.Parameters.Add("@Enter_Kyu", SqlDbType.NVarChar).Value = TextBox11.Text;       
      conn.Open();
      int rows = command.ExecuteNonQuery();   //// in these line i got a error message   
      conn.Close();
  
  }
  </code></pre>
  
  <p>can u help me friends plz</p>