用update修改数据库中的数据,调试时不报错,但数据还是原数据,并没有不变化!求各位大哥大姐帮忙
用update修改数据库中的数据,调试时不报错,但数据还是原数据,并没有不变化!求各位大哥大姐帮忙!!代码如下:
protected void Button2_Click(object sender, EventArgs e)
{
string GID;
if (Request["NetGraphID"] != null)
{
GID = Request.QueryString["NetGraphID"];
string NewUpdate = "update TrainGraphVerInfo set NetPlanID='" + DropDownList3.SelectedValue.ToString() + "',LineID='" + DropDownList1.SelectedValue.ToString() + "',UseDateType='" + DropDownList8.SelectedValue.ToString() + "',UploaderID='" + TextBox4.Text + "', UseFlag ='" + DropDownList2.SelectedValue.ToString() + "',PublisherID='" + TextBox6.Text + "' where NetGraphID ='" + int.Parse(GID).ToString()+"'";
SqlConnection myConn = new SqlConnection("Data Source=SC-201702031571;Integrated Security=True;Initial Catalog=UserData;User ID=sa;Password=***********");
SqlCommand mySqlCommand = new SqlCommand(NewUpdate, myConn);
myConn.Open();
mySqlCommand.CommandText = NewUpdate;
mySqlCommand.Connection = myConn;
int ni = mySqlCommand.ExecuteNonQuery();
if (ni > 0)
{
Response.Write(ShowMessage("修改成功"));
}
else
{
Response.Write(ShowMessage("修改失败"));
}
myConn.Close();
Response.Redirect(Request.Url.ToString());
}
}