- Rongsen.Com.Cn 版权所有 2008-2010 京ICP备08007000号 京公海网安备11010802026356号 朝阳网安编号:110105199号
- 北京黑客防线网安工作室-黑客防线网安服务器维护基地为您提供专业的
服务器维护
,企业网站维护
,网站维护
服务 - (建议采用1024×768分辨率,以达到最佳视觉效果) Powered by 黑客防线网安 ©2009-2010 www.rongsen.com.cn
作者:黑客防线网安MYSQL维护基地 来源:黑客防线网安MYSQL维护基地 浏览次数:0 |
这样所有的账户都改为dbo,即可。
下一步,把脚本命名为sqlscript.txt, 最好不要叫sqlscript.sql,下面会介绍。
然后通过ftp把脚本放到网站的空间。
编写脚本,例如命名为runsql.aspx ,然后运行该脚本即可还原数据库
<%
// Sample code for executing a T-SQL file using an ASP.NET page
// Copyright (C) Microsoft Corporation, 2007. All rights reserved.
// Written as a sample with use in conjuction with the SQL Server Database Publishing Wizard
// For more information visit http://www.codeplex.com/sqlhost/
// **************************************************************************
// Note: Please ensure that you delete this page once your database has been published to the remote server
// **************************************************************************
%>
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<%
// **************************************************************************
// Update these variables here
// **************************************************************************
// Url of the T-SQL file you want to run
string fileUrl = @"http://www.sohu.com/sqlscript.txt";
// Connection string to the server you want to execute against
string connectionString = @"Data Source=11.1.1.1;
User ID=hdd;Password=dd;Initial Catalog=s603";
// Timeout of batches (in seconds)
int timeout = 20000;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Executing T-SQL</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
<%
SqlConnection conn = null;
try
{
this.Response.Write(String.Format("Opening url {0}<BR>", fileUrl));
// read file
WebRequest request = WebRequest.Create(fileUrl);
using (StreamReader sr = new StreamReader(request.GetResponse().GetResponseStream()))
{
this.Response.Write("Connecting to SQL Server database...<BR>");
// Create new connection to database
conn = new SqlConnection(connectionString);
conn.Open();
while (!sr.EndOfStream)
{
StringBuilder sb = new StringBuilder();
SqlCommand cmd = conn.CreateCommand();
while (!sr.EndOfStream)
{
string s = sr.ReadLine();
if (s != null && s.ToUpper().Trim().Equals("GO"))
{
break;
}
sb.AppendLine(s);
}
// Execute T-SQL against the target database
cmd.CommandText = sb.ToString();
cmd.CommandTimeout = timeout;
cmd.ExecuteNonQuery();
}
}
this.Response.Write("T-SQL file executed successfully");
}
catch (Exception ex)
{
this.Response.Write(String.Format("An error occured: {0}", ex.ToString()));
}
finally
{
// Close out the connection
//
if (conn != null)
{
try
{
conn.Close();
conn.Dispose();
}
catch (Exception e)
{
this.Response.Write(String.Format(@"Could not close the connection. Error was {0}", e.ToString()));
}
}
}
%>
</body>
</html>
需要注意
string fileUrl = @“http://www.sohu.com/sqlscript.txt”;
我要申请本站:N点 | 黑客防线官网 | |
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479 |