一般处理程序,网页数据删除
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/html";
int qid = Convert.ToInt32(context.Request["id"]);
string str = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
string sql = "delete t_users where [email protected]";
using(SqlConnection conn=new SqlConnection (str))
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.Add(new SqlParameter("@id", qid));
conn.Open();
cmd.ExecuteNonQuery();
}
context.Response.Redirect("/index.ashx");
context.Response.ContentType = "text/html";
int qid = Convert.ToInt32(context.Request["id"]);
string str = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
string sql = "delete t_users where [email protected]";
using(SqlConnection conn=new SqlConnection (str))
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.Add(new SqlParameter("@id", qid));
conn.Open();
cmd.ExecuteNonQuery();
}
context.Response.Redirect("/index.ashx");
}
点击确定删除数据
删除完成。