ExecuteNonQuery 要求已打开且可用的连接。连接的当前状态为已关闭。
protected void lbtnDelete_Command(object sender, CommandEventArgs e){
if(Session["admin"]!=null)
{
string userID = ();
SqlCommand cmd = new SqlCommand();
cmd.Connection = DB.getConnection();
= "delete from guest where ID='"+userID+"'";
if (cmd.ExecuteNonQuery() > 0)
{
Response.Write("<script>alert('删除成功!');window.location=window.location;</script>");
}
else
{
Response.Write("<script>alert('删除失败!');window.location=window.location;</script>");
}
}
运行时出现“ExecuteNonQuery 要求已打开且可用的连接。连接的当前状态为已关闭。”这样的错误,是怎么回事呢 代码要怎么写啊,请各位帮我看看,谢谢!