日期:2014-05-17 浏览次数:20425 次
SqlConnection conn=new SqlConnection("连接语句"); SqlCommand comm=new Command("删除语句",conn); int result=comm.ExecuteNonQuery(); return result;
------解决方案--------------------
SqlConnection conn=new SqlConnection("连接字符串"); SqlCommand comm=new Command("select count(*) from 表 where……",conn); int result=comm.ExecuteNonQuery(); return result; if(result>0) { SqlCommand cmd=new Command("delete from 表 where……",conn); int result=cmd.ExecuteNonQuery(); return result1; if(result>0) { Response.Write("<script>alert('删除成功!');</script>"); } else { Response.Write("<script>alert('删除失败!');</script>"); } } else { Response.Write("<script>alert('数据不存在!');</script>"); }