; oSQLServer.DisConnect();
32 }
33 }
2.实现数据库恢复:
在恢复时要注意先杀掉当前数据库的所有进程
1/**//// <summary>
2 /// 数据库恢复
3 /// </summary>
4 public string DbRestore()
5 {
6 if(exepro()!=true)//执行存储过程
7 {
8 return "操作失败";
9 }
10 else
11 {
12 SQLDMO.Restore oRestore = new SQLDMO.RestoreClass();
13 SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass();
14 try
15 {
16 exepro();
17 oSQLServer.LoginSecure = false;
18 oSQLServer.Connect(server, uid, pwd);
19 oRestore.Action = SQLDMO.SQLDMO_RESTORE_TYPE.SQLDMORestore_Database;
20 oRestore.Database = database;
21 /**////自行修改
22 oRestore.Files = @"d:\aaa\aaa.bak";
23 oRestore.FileNumber = 1;
24 oRestore.ReplaceDatabase = true;
25   |