在这段代码中,我想更新contact_no
字段,但它不工作,并且我想在更新,删除或插入后设置刷新。如何设置刷新后点击更新,删除,插入按钮
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
{
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();
}
}
请提供更多关于上下文的信息。看起来像Windows Phone。 TextBo_num的价值是什么? – sprinter252