private void Button1_Click(object sender, System.EventArgs e)
{
string editId = Request["New_Id"].ToString();
string tTitle = this.TextBox1.Text.ToString();
string tClass = this.TextBox2.Text.ToString();
string tContent = this.TextBox3.Text.ToString();
string tAuthor = this.TextBox4.Text.ToString();
SqlConnection updateCon = Db.CreateCon();
updateCon.Open();
SqlCommand updateCmd = new SqlCommand ("update News_List set (News_Title,News_Class,News_Content,News_Author) = ('"+tTitle+"','+tClass+','tContent','+tAuthor+') where New_Id='"+editId+"'",updateCon);
updateCmd.ExecuteNonQuery();
Response.Write("<script language='javascript'>alert('修改成功');</script>");
}
但是老是报错。好象不能批修改,麻烦大侠们帮我看看 我菜鸟
{
string editId = Request["New_Id"].ToString();
string tTitle = this.TextBox1.Text.ToString();
string tClass = this.TextBox2.Text.ToString();
string tContent = this.TextBox3.Text.ToString();
string tAuthor = this.TextBox4.Text.ToString();
SqlConnection updateCon = Db.CreateCon();
updateCon.Open();
SqlCommand updateCmd = new SqlCommand ("update News_List set (News_Title,News_Class,News_Content,News_Author) = ('"+tTitle+"','+tClass+','tContent','+tAuthor+') where New_Id='"+editId+"'",updateCon);
updateCmd.ExecuteNonQuery();
Response.Write("<script language='javascript'>alert('修改成功');</script>");
}
但是老是报错。好象不能批修改,麻烦大侠们帮我看看 我菜鸟
private void Button1_Click(object sender, System.EventArgs e)
{
string editId = Request["New_Id"].ToString();
string tTitle = this.TextBox1.Text.ToString();
string tClass = this.TextBox2.Text.ToString();
string tContent = this.TextBox3.Text.ToString();
string tAuthor = this.TextBox4.Text.ToString();
SqlConnection updateCon = Db.CreateCon();
updateCon.Open();
SqlCommand updateCmd = new SqlCommand ("update News_List set News_Title= '"+tTitle+"',News_Class = '"+tClass+"',News_Content = '"+tContent"',News_Author = '"+tAuthor+"' where New_Id='"+editId+"'",updateCon);
updateCmd.ExecuteNonQuery();
Response.Write("<script language='javascript'>alert('修改成功');</script>");
}
("update News_List set (News_Title,News_Class,News_Content,News_Author) = ('"+tTitle+"','+tClass+','tContent','+tAuthor+') where New_Id='"+editId+"'"自己认真核对下少了多少个双引号?新手也不能这么不认真吧!