| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1907 人关注过本帖
标题:数据库还原 (转载)
只看楼主 加入收藏
xingehappy
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2004-4-14
收藏
 问题点数:0 回复次数:2 
数据库还原 (转载)
数据库还原 wsd309(原作) '引用sqldmo object library Dim gSQLServer As SQLDMO.SQLServer On Error GoTo ErrHandler: If gSQLServer Is Nothing Then Set gSQLServer = New SQLDMO.SQLServer End If gSQLServer.LoginTimeout = 15 frmSelectServer.Show 1 If frmSelectServer.connecString = "" Then Exit Sub gSQLServer.Connect frmSelectServer.connecString, "sa", "sa" Dim oRestore As SQLDMO.Restore Dim Msg As String Dim Response As String Set oRestore = New SQLDMO.Restore oRestore.DATABASE = "data" CommonDialog1.CancelError = True On Error GoTo Errhandler1 ' 设置标志 CommonDialog1.Flags = cdlOFNHideReadOnly ' 设置过滤器 CommonDialog1.Filter = "All Files (data*.*)|data*.*" ' 指定缺省的过滤器 CommonDialog1.FilterIndex = 2 ' 显示“打开”对话框 ' Dim riqi As String CommonDialog1.FileName = riqi CommonDialog1.ShowOpen ' 显示选定文件的名字 riqi = CommonDialog1.FileName oRestore.Files = riqi '当连接的时候,鼠标变化 Screen.MousePointer = vbHourglass '恢复前断开所有的数据库连接 Dim iDb As ADODB.Connection, iRe As ADODB.Recordset Set iDb = New ADODB.Connection Set iRe = New ADODB.Recordset Dim iConcStr As String '连接数据库服务器 iConcStr = "Provider=sqloledb;" & _ "Data Source=myServerName;" & _ "Initial Catalog=master;" & _ "User Id=myUsername;" & _ "Password=myPassword" iDb.Open iConcStr Dim iSql As String iSql = "select spid from master..sysprocesses where dbid=db_id('data')" iRe.Open iSql, iDb, adOpenKeyset, adLockReadOnly frmMoive.Label1.Caption = "数据库在还原过程中,请等候。" frmMoive.Caption = "数据库恢复" frmMoive.Show vbModeless, Me DoEvents Me.Enabled = False Dim Spath As String If Right(App.Path, 1) <> "\" Then Spath = App.Path & "\" Else Spath = App.Path End If frmMoive.Animation1.Open Spath & "working.avi" frmMoive.Animation1.Play While iRe.EOF = False iSql = "kill " & iRe(0) iDb.Execute iSql iRe.MoveNext Wend iRe.Close iDb.Close '恢复数据库 oRestore.SQLRestore gSQLServer '恢复后鼠标返回默认的状态 Me.Enabled = True frmMoive.Animation1.Stop Unload frmMoive Set oRestore = Nothing Screen.MousePointer = vbDefault MsgBox "数据库还原成功!" Exit Sub ErrHandler: MsgBox "Error " & Err.Description Exit Sub Errhandler1: ' 用户按了“取消”按钮 Exit Sub
搜索更多相关主题的帖子: 数据库 
2004-04-15 19:23
pigpigpig
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2004-4-18
收藏
得分:0 

怎么有的东西不能回复呢?

想多支持你都不行了,埃!


没有做不到的,只有想不到的!
2004-04-23 08:36
xingehappy
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2004-4-14
收藏
得分:0 

不好意思!!最近有些忙!!没能及时回论坛上的贴子!请见谅!!


我又回頭去飛,去追.就算我追到最后只剩冰雪.天都為我傷悲.冷的愛快枯萎.任漫天風雪覆蓋我的心碎........
2004-04-24 15:53
快速回复:数据库还原 (转载)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024657 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved