用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;
 
相关文档:
在早期的ASP.NET框架中,如果你放置一个控件在一个容器中,如GridView模板列、登录模板、其它,在运行时这些控件的ID将被替换由ASP.NET自身产生的随机唯一ID。
为开发者提供服务方访问控件的Page.FindControl("controlid")以及JavaScript中使用 的document ......
在ASP.NET项目开发中,会被要求添加广告,有翻屏效果、有广告轮流显示、飘浮广告、左侧广告、右侧广告等。用本贴持续记录一些收集的广告效果。希望给有需求的朋友们一些支持。也希望朋友们把我未记录的广告形式也给予一起回贴。使本贴更加的完善,也让更多的朋友们分享。
1.翻屏效果
翻屏效果
<html>
<head>& ......
需求:
A域有页面a.html,其中有iframe包含B域的页面b.html,现在要通过a.html上的一个按钮,来把a.html页面上一个文本框的值传递到b.html页面的文本框。
注:这里b.html是html网页,不能接收其他网站post过来的值,所以不能用直接post的方法来传值,但是,如果接收页面是b.aspx或者b.asp 呢,那不是可以直接post了么?答 ......
/// <summary>
/// 写Cookies
/// </summary>
/// <param name="response"></param>
/// <param name="request"></param>
&n ......