我试图用我的web应用程序中的1个按钮更新2个不同的表格。我目前正在使用asp.net开发我的web应用程序。我想知道是否有可能从2个不同的表中更新2个不同的列。用asp.net中的1个按钮更新2个不同的表格
这里是我的后端代码
protected void btnAssign_Click(object sender, EventArgs e)
{
//SqlConnection connAdd = new SqlConnection("Data Source = localhost; Initial Catalog = project; Integrated Security= SSPI");
//connAdd.Open();
//string mySQL;
//mySQL = "Update LoginRegisterPoliceOfficer Set caseid ='" + lblCID.Text + "' where fullname ='" + DDLpolice.SelectedItem.Text + "'";
//SqlCommand cmdAdd = new SqlCommand(mySQL, connAdd);
//cmdAdd.ExecuteNonQuery();
//connAdd.Close();
SqlConnection connAdd = new SqlConnection("Data Source = localhost; Initial Catalog = project; Integrated Security= SSPI");
connAdd.Open();
string mySQLL;
mySQLL = "Update Report Set handle = 'handled' where caseid='"+lblCID.Text+"'";
SqlCommand cmdAdd = new SqlCommand(mySQLL, connAdd);
cmdAdd.ExecuteNonQuery();
connAdd.Close();
}
我只能够更新1,但失败,第二次更新。因此,我注释掉了我的一个sql代码。
谢谢你的工作。 :) –