我用下面的代码直接能删除了,但是不执行提示的JS代码,请问如何修改?
是删除后,不是删除前,请大家帮忙!OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;Data Source=" + Server.MapPath("db/sl.mdb"));
OleDbCommand cmd = new OleDbCommand();
conn.Open(); cmd.CommandText = "delete from news where id=" + Convert.ToInt32(Request.QueryString["delid"]) + " ";
cmd.Connection = conn; int i = Convert.ToInt32(cmd.ExecuteScalar());
if (i > 0)
{
Response.Write("<script>alert('删除成功');</script>");
Response.Redirect("ado_access.aspx");
}
else
{
Response.Write("<script>alert('删除失败');</script>");
Response.Redirect("ado_access.aspx");
} //关闭数据库连接
conn.Close();
//释放资源
conn.Dispose();
是删除后,不是删除前,请大家帮忙!OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;Data Source=" + Server.MapPath("db/sl.mdb"));
OleDbCommand cmd = new OleDbCommand();
conn.Open(); cmd.CommandText = "delete from news where id=" + Convert.ToInt32(Request.QueryString["delid"]) + " ";
cmd.Connection = conn; int i = Convert.ToInt32(cmd.ExecuteScalar());
if (i > 0)
{
Response.Write("<script>alert('删除成功');</script>");
Response.Redirect("ado_access.aspx");
}
else
{
Response.Write("<script>alert('删除失败');</script>");
Response.Redirect("ado_access.aspx");
} //关闭数据库连接
conn.Close();
//释放资源
conn.Dispose();
this.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('删除成功')</script>");
换成
Respon.Write("<script>window.location.href='ado_access.aspx';</script>")
ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除成功');location.href='ado_access.aspx';</script>");
谢谢大家,结贴了