ExecuteNonQuery 要求已打开且可用的连接。连接的当前状态为已关闭。
protectedvoidlbtnDelete_Command(objectsender,CommandEventArgse){if(Session["admin"]!=...
protected void lbtnDelete_Command(object sender, CommandEventArgs e)
{
if(Session["admin"]!=null)
{
string userID = e.CommandArgument.ToString();
SqlCommand cmd = new SqlCommand();
cmd.Connection = DB.getConnection();
cmd.CommandText = "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 要求已打开且可用的连接。连接的当前状态为已关闭。”这样的错误,是怎么回事呢 代码要怎么写啊,请各位帮我看看,谢谢! 展开
{
if(Session["admin"]!=null)
{
string userID = e.CommandArgument.ToString();
SqlCommand cmd = new SqlCommand();
cmd.Connection = DB.getConnection();
cmd.CommandText = "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 要求已打开且可用的连接。连接的当前状态为已关闭。”这样的错误,是怎么回事呢 代码要怎么写啊,请各位帮我看看,谢谢! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询