restore.aspx.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Security;
using DbPrvd;
public partial class restore : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["User"] == null || Session["Role"] == null)
Response.Write("<script type='text/javascript'>parent.document.location='timeout.htm';</script>");
if (Session["Role"].ToString() != "管理员")
{
Response.Write("<script type='text/javascript'>alert('您无权操作');history.go(-1);</script>");
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
string path = this.FileUpload1.PostedFile.FileName; //获得备份路径及数据库名称
string restoreQuery = "use master restore database mall from disk='" + path + "'";
string connstr = SqlHelper.ConStr;
SqlConnection con = new SqlConnection(connstr);
con.Open();
try
{
SqlCommand com = new SqlCommand();
com.Connection = con;
//com.CommandType = CommandType.StoredProcedure;
//com.CommandText = "killspid";
//com.ExecuteNonQuery();
com.CommandType = CommandType.Text;
com.CommandText = restoreQuery;
Response.Write("<script type='text/javascript'>alert('操作成功');</script>");
}
catch (Exception error)
{
Response.Write(error.Message);
Response.Write("<script language=javascript>alert('备份数据失败!')</script>");
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。