📄 backuprestore.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmBakupRestore
BorderStyle = 3 'Fixed Dialog
Caption = "数据备份/恢复"
ClientHeight = 1545
ClientLeft = 45
ClientTop = 330
ClientWidth = 5130
Icon = "BackUpReStore.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1545
ScaleWidth = 5130
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame2
Caption = "请输入文件名"
Height = 885
Left = 60
TabIndex = 2
Top = 60
Width = 4965
Begin VB.TextBox txtPath
Height = 330
Left = 180
TabIndex = 4
Top = 330
Width = 4065
End
Begin VB.CommandButton cmdPath
Caption = "..."
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 345
Left = 4320
TabIndex = 3
Top = 330
Width = 405
End
End
Begin VB.CommandButton cmdStart
Caption = "开始"
Height = 375
Left = 2370
TabIndex = 1
Top = 1080
Width = 1275
End
Begin VB.CommandButton cmdClose
Caption = "关闭"
Height = 375
Left = 3750
TabIndex = 0
Top = 1080
Width = 1275
End
Begin MSComDlg.CommonDialog comdlg
Left = 60
Top = 2130
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
End
Attribute VB_Name = "frmBakupRestore"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public mbBak As Boolean '判断是备份还是恢复
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdPath_Click()
If mbBak Then
'备份数据
comdlg.DialogTitle = "请选择要备份的路径"
comdlg.Filter = "*.dat|*.dat"
comdlg.ShowSave
txtPath = comdlg.FileName
Else
'恢复数据
comdlg.DialogTitle = "恢复备份的文件"
comdlg.Filter = "*.dat|*.dat"
comdlg.ShowOpen
txtPath = comdlg.FileName
End If
End Sub
Private Function mbStart() As Boolean
'*********************************************
'开始执行备份或恢复
'
Dim sSQL As String
On Error GoTo ErrStart
If txtPath.Text = "" Then
MsgBox "请输入文件名!!!", vbInformation, ""
mbStart = False
Exit Function
End If
sSQL = "Use Master"
If mbBak Then
sSQL = sSQL & vbCrLf & "BackUp Database Archives to Disk = '" & txtPath & "'"
Else
If MsgBox("你确实要恢复数据吗?", vbQuestion + vbYesNo, "") = vbYes Then
sSQL = sSQL & vbCrLf & "Restore Database Archives from Disk = '" & txtPath & "'"
Else
mbStart = False
Exit Function
End If
End If
sSQL = sSQL & vbCrLf & "Use Archives"
Screen.MousePointer = vbHourglass
CN.Execute sSQL
Screen.MousePointer = vbDefault
mbStart = True
Exit Function
ErrStart:
mbStart = False
Screen.MousePointer = vbDefault
MsgBox "备份或恢复数据出错,请校验路径及文件名是否有误!!!", vbInformation, ""
Err.Clear
End Function
Private Sub cmdStart_Click()
If mbStart Then
If mbBak Then
MsgBox "数据库备份成功!!!", vbInformation + vbOKOnly, ""
Else
MsgBox "数据库恢复成功!!!", vbInformation + vbOKCancel, ""
End If
End If
End Sub
Private Sub Form_Load()
Center Me
If mbBak Then
Me.Caption = "备份数据"
'lblNote.Caption = "备份数据可以把数据库中的数据备份成文件形式保存,要注意及时备份,以防止数据库损坏或电脑重装后带来的数据丢失!!!"
Else
Me.Caption = "恢复数据"
'lblNote.Caption = "恢复数据时会将数据库中的数据覆盖,一旦恢复了就不能还原,所以使用时要注意!!!"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -