with this code i am performing update...but whenever i am updating with the existing data is showing "record updated "...this i dont want...behalf of this i want record cant be updated becoz data is already exist...so how can i do this....help..
protected void Button2_Click(object sender, EventArgs e)//Update
{
if (TexBo_num.Text == "" && TexBo_num.Text != "contact_no" )
{
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('contact number not be empty');", true);
}
else if(TxtBox_name.Text=="name" && TexBo_add.Text=="address" && TexBo_num.Text=="contact_no")
{
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('can't update the same record');", true);
}else
{
SqlConnection con = new SqlConnection(@"Data Source=SYSTEM2\SQLEXPRESS;Initial Catalog=amresh;Integrated Security=True");
SqlCommand cmd = new SqlCommand("UPDATE detail SET name='" + TxtBox_name.Text + "',address='" + TexBo_add.Text + "',contact_no='" + TexBo_num.Text + "' WHERE contact_no='" + TexBo_num.Text + "'", con);
con.Open();
cmd.ExecuteNonQuery();
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('record updated');", true);
con.Close();
}
}