易截截图软件、单文件、免安装、纯绿色、仅160KB

用asp.net还原与恢复sqlserver数据库


  
上次做了个项目,涉及到数据库的还原和恢复,到网上找了一下,是利用SQLDMO实现的,只要添加SQLDMO引用就好了,
然后利用下边的类的方法就可以实现了。
我把原作者的类扩充了一下,可以自动识别web.config里 的数据库连接字符串,可以通过变量设置还原恢复的信息。
需要注意的时还原,还原的时候问题最大了,有别的用户使用数据库的时候无法还原,解决办法就是在MASTER数据库中
添加一个存储过程:
create proc killspid (@dbname varchar(20))
as
begin
declare @sql nvarchar(500)
declare @spid int
set @sql='declare getspid cursor for 
select spid from sysprocesses where dbid=db_id('''+@dbname+''')'
exec (@sql)
open getspid
fetch next from getspid into @spid
while @@fetch_status<>-1
begin
exec('kill '+@spid)
fetch next from getspid into @spid
end
close getspid
deallocate getspid
end
GO
在还原之前先执行这个存储过程,需要传递dbname,就是你的数据库的名字。下边是类的原代码:(web.config里的数
据库连接字符串是constr)
using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
namespace web.base_class
{
     /// <summary>
     /// DbOper类,主要应用SQLDMO实现对Microsoft SQL Server数据库的备份和恢复
     /// </summary>
     public class DbOper
     {
          private string server;
          private string uid;
          private string pwd;
          private string database;
          private string conn;
         /// <summary>
         /// DbOper类的构造函数
         /// </summary>
    


相关文档:

asp.net(C#)实现SQL2000数据库备份和还原

asp.net(C#)实现SQL2000数据库备份和还原
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.Htm ......

asp.net 无法破解的软件注册码算法

http://files.cnblogs.com/chengulv/SoftRegion.rar
Microsoft .Net的应用程序的代码文件,与Java生成的文件类似,它们都没有本地代码,而是一种类似于汇编的代码。这样,只要有合适的工具,就可以完整的把别人写出来的程序反编译成自己需要的程序文件。
我所知道的.Net下的反汇编程序是Salamander 和 Refelector 两个工 ......

站点地图在ASP.NET网页中的导航作用

    在ASP.NET2.0中,为我们提供了两种新功能,方便我们制作共同特征一致的页面和导航。这两种功能是母板页和网站导航。对于母板页大家很清楚了,不过在做母板页时,经常需要添加导航栏,对于此asp.net 2.0 使我们的工作大为简化。这便是站点地图的使用。
    顾名思义,站点地图就是在站点 ......

asp.net 图片处理 获取图片宽度和高度

1.获取图片宽度和高度
    1.您可以使用 System.Drawing.Image 类
    System.Drawing.Image img = System.Drawing.Image.fromFile(Server.MapPath("example.gif"));
int width = img.Width;
int height = img.Height;
img.Dispose();
但是这里我们却不能在导入名称空间后使用 Image& ......

asp.net中关于&,双引号和单引号的用法

 关于&、双引号、和单引号的解释
 
下面先简单地说一下他们的意义。
      (1)&是连接运算符,它可以将两个字符串连接成一个字符串。如 
         a="abc" & "def" 
 执行连接运算后,a="abcdef ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号