📄 frmdatahuan.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmDataHuan
BackColor = &H80000009&
BorderStyle = 1 'Fixed Single
Caption = "数据库恢复"
ClientHeight = 4560
ClientLeft = 45
ClientTop = 330
ClientWidth = 5895
Icon = "frmDataHuan.frx":0000
LinkTopic = "恢复数据库"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4560
ScaleWidth = 5895
StartUpPosition = 2 '屏幕中心
Begin MSComDlg.CommonDialog CommonDialog1
Left = 720
Top = 1800
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton CmdBrowser
Caption = "浏 览"
Height = 375
Left = 4680
TabIndex = 3
Top = 1320
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "退 出"
Height = 375
Left = 4080
TabIndex = 2
Top = 3720
Width = 1335
End
Begin VB.CommandButton CmdRenew
Caption = "恢 复"
Height = 375
Left = 2640
TabIndex = 1
Top = 3720
Width = 1215
End
Begin VB.TextBox TxtDir
Height = 375
Left = 2280
TabIndex = 0
Top = 840
Width = 3495
End
Begin VB.Label Label2
BackColor = &H80000009&
Caption = "注:在恢复数据库前,强烈建议一定要先进行备份数据,否则,进行此操作造成的数据损失是无法还原的!!"
Height = 855
Left = 2520
TabIndex = 5
Top = 2400
Width = 3015
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H00FFFFFF&
Caption = "恢复从:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 2280
TabIndex = 4
Top = 480
Width = 840
End
Begin VB.Image Image1
Height = 4710
Left = -240
Picture = "frmDataHuan.frx":0152
Top = 0
Width = 3075
End
End
Attribute VB_Name = "frmDataHuan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'恢复数据库功能
'实现方法:从备份后的.bk文件拷贝到当前目录下.
Option Explicit
Dim rs As New ADODB.Recordset
Dim SourceFile As String '原文件名
Dim DestinationFile As String '目的文件
Private Sub CmdBrowser_Click()
CmdRenew.Enabled = True
On Error GoTo EndSub
With CommonDialog1
.CancelError = True
.DialogTitle = "请选择已备份文件的目录和文件名"
.Filter = "备份文件(*.BK)|*.BK|"
.FileName = TxtDir.Text
'.Flags = cdlOFNNoChangeDir
.ShowOpen
End With
If CommonDialog1.FileName = "" Then
Exit Sub
End If
TxtDir.Text = CommonDialog1.FileName
Exit Sub
EndSub:
If Err.Number = 32755 Then
Err.Clear
Exit Sub
End If
If Err.Number = 20477 Then
Err.Clear
On Error Resume Next
With CommonDialog1
.CancelError = False
.DialogTitle = "请选择已备份文件的目录和文件名"
.Filter = "备份文件(*.BK)|*.BK|"
.FileName = ""
On Error Resume Next
.ShowOpen
If Err.Number <> 0 Then
Err.Clear
Exit Sub
End If
End With
If CommonDialog1.FileName = "" Then
Exit Sub
End If
TxtDir.Text = CommonDialog1.FileName
End If
End Sub
Private Sub CmdRenew_Click()
If TxtDir.Text = "" Then
MsgBox "请先指定欲恢复的文件的路径和文件名!", vbOKOnly + vbExclamation, "提示"
TxtDir.SetFocus
Exit Sub
End If
Me.Caption = "正在恢复数据,请稍候..."
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim y As Variant
y = fso.CopyFile(CommonDialog1.FileName, App.Path & "\kcgl.mdb")
MsgBox "恢复数据库成功!"
Me.Caption = "恢复完成!"
Me.MousePointer = vbDefault
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
frmMDIMain.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmMDIMain.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -