后台:protected void btnDiaoAll_Click(object sender, EventArgs e)
{
string id = hf.Value;
string oper = Request.Cookies["ckuser"].ToString();//就这里出错 if (BaojianAspNet.BLL.MaterialAssignBLL.ExecuteNonQuery(id, DateTime.Now.ToLocalTime(),oper) >= 0)
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('调派成功!');", true);
else
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('调派失败!');", true);
} 底层DAL:public static int ExecuteNonQuery(string id, DateTime time, string oper)
{
string sql = "update MaterialAssign set State = '1',FinishDat= @date,oper=@oper where pk in(" + id + ")";
SqlParameter[] para ={
new SqlParameter("@date", time),
new SqlParameter("@oper", oper)
};
return SqlHelper.ExecuteNonQuery("", CommandType.Text, sql, para);
}
不知道为什么错了~~~~
{
string id = hf.Value;
string oper = Request.Cookies["ckuser"].ToString();//就这里出错 if (BaojianAspNet.BLL.MaterialAssignBLL.ExecuteNonQuery(id, DateTime.Now.ToLocalTime(),oper) >= 0)
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('调派成功!');", true);
else
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('调派失败!');", true);
} 底层DAL:public static int ExecuteNonQuery(string id, DateTime time, string oper)
{
string sql = "update MaterialAssign set State = '1',FinishDat= @date,oper=@oper where pk in(" + id + ")";
SqlParameter[] para ={
new SqlParameter("@date", time),
new SqlParameter("@oper", oper)
};
return SqlHelper.ExecuteNonQuery("", CommandType.Text, sql, para);
}
不知道为什么错了~~~~
if (!string.IsNullOrEmpty(Request.Cookies["ckuser"]))
{
string oper = Request.Cookies["ckuser"].ToString();
}
{
string oper = Request.Cookies["ckuser"].ToString();
}
先判断 coolies是否存在,不然request对象去哪找这个ckuser这个参数呢
你的cookie值就没有获取到啊。 if (Request.Cookies["ckuser"] != null)
{
string oper = Request.Cookies["ckuser"].ToString();}