📄 frmrestore.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form frmrestore
BorderStyle = 1 'Fixed Single
Caption = "数据库还原"
ClientHeight = 1995
ClientLeft = 45
ClientTop = 330
ClientWidth = 3630
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 1995
ScaleWidth = 3630
Begin VB.Frame Frame2
Caption = "恢复"
Height = 1815
Left = 120
OLEDropMode = 1 'Manual
TabIndex = 0
Top = 120
Width = 3375
Begin MSComDlg.CommonDialog CommonDialog2
Left = 360
Top = 1320
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command2
Caption = "<<"
Height = 375
Left = 2880
TabIndex = 5
Top = 720
Width = 375
End
Begin VB.TextBox Text2
Height = 375
Left = 120
TabIndex = 4
Top = 720
Width = 2655
End
Begin VB.CommandButton Command6
Caption = "取消"
Height = 375
Left = 2280
TabIndex = 2
Top = 1320
Width = 975
End
Begin VB.CommandButton Command5
Caption = "开始恢复"
Height = 375
Left = 1080
TabIndex = 1
Top = 1320
Width = 975
End
Begin VB.Label Label2
Caption = "请输入或选择数据恢复的路径"
Height = 255
Left = 240
TabIndex = 3
Top = 360
Width = 2415
End
End
End
Attribute VB_Name = "frmrestore"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim con As New ADODB.Connection
Dim sql As String
Private Sub Command2_Click()
CommonDialog2.Filter = "备份文件(*.bak)|*.bak|文本文件(*.txt)|*.txt|ALL File(*.*)|*.*"
CommonDialog2.ShowOpen
Text2.Text = CommonDialog2.FileName
End Sub
Private Sub Command5_Click()
On Error GoTo err1
If Text2.Text = "" Then
MsgBox "请您选择数据库恢复的路径!", 64, "提示信息"
Else
con.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=wx;Initial Catalog=wxdb"
sql = "RESTORE DATABASE wxdb from disk='" & Text2.Text & "'" '恢复数据库
con.Execute (sql) '执行SQL语句
MsgBox "数据库恢复成功!!", 64, "提示信息"
End If
Exit Sub
err1:
MsgBox Err.Description
con.Close
End Sub
Private Sub Command6_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -