📄 restoredb.frm
字号:
VERSION 5.00
Begin VB.Form restoreDB
Caption = "restore database"
ClientHeight = 1770
ClientLeft = 6345
ClientTop = 6030
ClientWidth = 5475
LinkTopic = "Form1"
ScaleHeight = 1770
ScaleWidth = 5475
Begin VB.CommandButton Command2
Caption = "Cancel"
Height = 375
Left = 3120
TabIndex = 3
Top = 1080
Width = 735
End
Begin VB.CommandButton Command1
Caption = "Restore"
Height = 375
Left = 1200
TabIndex = 2
Top = 1080
Width = 855
End
Begin VB.ComboBox Combo2
Height = 300
Left = 2280
TabIndex = 0
Top = 360
Width = 3015
End
Begin VB.Label Label1
Caption = "请选择备份的数据源:"
Height = 255
Left = 120
TabIndex = 1
Top = 360
Width = 2175
End
End
Attribute VB_Name = "restoreDB"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim dircom As ADODB.command
Dim rst As ADODB.Recordset
Private Sub Command1_Click()
If Me.Combo2.Text <> "" Then
Me.MousePointer = 11 '改变鼠标样子
dircom.CommandText = " RESTORE DATABASE [mcad_zs] FROM DISK = N'" + bakpath + "mcad_zs.bak' WITH FILE =" & (Me.Combo2.ListCount - Me.Combo2.ListIndex) & ",NOUNLOAD,STATS = 10,RECOVERY,REPLACE,MOVE N'MCAD_zs' TO N'" + dbpath + "mcad_zs.mdf',MOVE N'MCAD_zs_log' TO N'" + dbpath + "mcad_zs_log.ldf'"
On Error GoTo erro
dircom.Execute , , 1
erro:
Me.MousePointer = 0 '改变鼠标样子
MsgBox err.Description + Chr(13) + Chr(10) + "数据库还原完成!"
Unload Me
Else
MsgBox "请选择要还原的数据库文件!"
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Width = 5595
Me.Height = 2280
Set dircom = New ADODB.command
Set rst = New ADODB.Recordset
dircom.ActiveConnection = adoconn
dircom.CommandText = "restore headeronly from DISK = N'" + bakpath + "mcad_zs.bak'"
Set rst = dircom.Execute(, , 1)
Dim n As Integer
n = -1
While Not rst.EOF
Combo2.AddItem " "
n = n + 1
rst.MoveNext
Wend
rst.MoveFirst
While n >= 0
Combo2.RemoveItem n
Combo2.AddItem Trim _
(rst.Fields("databasename")) & " | " & rst.Fields("backupfinishdate"), n
rst.MoveNext
n = n - 1
Wend
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -