📄 back.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form back
BorderStyle = 4 'Fixed ToolWindow
Caption = "数据备份与恢复"
ClientHeight = 3825
ClientLeft = 45
ClientTop = 285
ClientWidth = 6975
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3825
ScaleWidth = 6975
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin MSAdodcLib.Adodc Adodc1
Height = 495
Left = 2760
Top = 4440
Visible = 0 'False
Width = 1935
_ExtentX = 3413
_ExtentY = 873
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Frame Frame1
Height = 3825
Index = 0
Left = 0
TabIndex = 0
Top = 0
Width = 6975
Begin VB.CommandButton Command1
Appearance = 0 'Flat
Caption = "EXIT"
Height = 375
Left = 5520
TabIndex = 10
Top = 3240
Width = 975
End
Begin VB.CommandButton cmdSource
Caption = "..."
Height = 285
Left = 1800
TabIndex = 4
Top = 1995
Width = 375
End
Begin VB.TextBox txtSource
Height = 285
Left = 2295
TabIndex = 3
Top = 1980
Width = 4110
End
Begin VB.TextBox txtDestination
Height = 285
Left = 2205
TabIndex = 2
Top = 540
Width = 4155
End
Begin VB.CommandButton cmdDestination
Caption = "..."
Height = 285
Left = 1785
TabIndex = 1
Top = 540
Width = 375
End
Begin MSComctlLib.Toolbar Toolbar2
Height = 600
Left = 240
TabIndex = 5
Top = 1800
Width = 1365
_ExtentX = 2408
_ExtentY = 1058
ButtonWidth = 2408
ButtonHeight = 1005
Style = 1
TextAlignment = 1
ImageList = "ImageList2"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 1
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "数据恢复"
Object.ToolTipText = "从存在的磁盘数据进行导入"
ImageIndex = 2
EndProperty
EndProperty
BorderStyle = 1
End
Begin MSComctlLib.Toolbar Toolbar1
Height = 600
Left = 240
TabIndex = 6
Top = 360
Width = 1395
_ExtentX = 2461
_ExtentY = 1058
ButtonWidth = 2408
ButtonHeight = 1005
Style = 1
TextAlignment = 1
ImageList = "ImageList2"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 1
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "数据备份"
Object.ToolTipText = "将数据库数据进行备份"
ImageIndex = 1
EndProperty
EndProperty
BorderStyle = 1
End
Begin VB.Label lblStatus
Alignment = 2 'Center
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 480
TabIndex = 9
Top = 2160
Width = 5895
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "从本地硬盘上把备份的数据库文件重新恢复并覆盖原来的数据"
Height = 225
Left = 480
TabIndex = 8
Top = 2640
Width = 5940
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "把数据库入的数据备份到本地硬盘,以备以后使用"
Height = 210
Left = 480
TabIndex = 7
Top = 1095
Width = 5505
End
End
Begin MSComctlLib.ImageList ImageList2
Left = 240
Top = 120
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 32
ImageHeight = 32
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 2
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "back.frx":0000
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "back.frx":0CDA
Key = ""
EndProperty
EndProperty
End
End
Attribute VB_Name = "back"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim dbasize2 As Long
Dim dbasize As Long
Dim PathName As String
Private Sub cmdDestination_Click()
Dim strTemp As String
strTemp = fBrowseForFolder(Me.hwnd, "Select backup path")
If strTemp <> "" Then
txtDestination = strTemp
End If
End Sub
Private Sub cmdSource_Click()
On Error GoTo Erro
Dim strTemp As String
strTemp = fBrowseForFolder(Me.hwnd, "Restore From")
If strTemp <> "" Then
txtSource = strTemp
dbasize2 = FileLen(txtSource & "\db.MDB")
lblSelectedDba = "Selected Backup Database is : " & Format((dbasize2 / 1024) / 1024, "standard") & "MB."
cmdRestore.Enabled = True
End If
Erro:
Select Case err.Number
Case 53 'File Not Found
lblSelectedDba = "No Backup at this location"
Toolbar2.Enabled = False
End Select
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Activate()
lblSize = Format((dbasize / 1024) / 1024, "standard") & "MB."
End Sub
Private Sub Form_Load()
Dim cnn1 As ADODB.Connection
Dim rstschema As ADODB.Recordset
Dim strcnn As String
Set cnn1 = New ADODB.Connection
strcnn = "provider=Microsoft.jet.oledb.4.0;" & "data source=" & App.Path & "\db.mdb"
cnn1.Open strcnn
Set rstschema = cnn1.OpenSchema(adSchemaTables)
Do Until rstschema.EOF
temp = rstschema!Table_Name
If Left(temp, 1) <> "M" Then
End If
rstschema.MoveNext
Loop
cnn1.Close
On Error GoTo err
PathName = App.Path & "\db.MDB"
dbasize = FileLen(PathName)
err:
Exit Sub
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
If txtDestination <> "" Then
DoBackup PathName, txtDestination
MsgBox "备份成功!", , "提示"
ElseIf txtDestination = "" Then
MsgBox "You must specify a distination for the backup", vbCritical
End If
End Sub
Private Sub Toolbar2_ButtonClick(ByVal Button As MSComctlLib.Button)
If MsgBox("Restoring database from location " & txtSource & " will replace existing database files.Do you want to Contunue", vbYesNo) = vbYes Then
DoRestore txtSource.Text, App.Path
If NoDba = True Then
MsgBox "Database Restored Click Ok to Exit Program"
frmRestoreDba.Hide
Unload frmRestoreDba
End If
Else
lblStatus.Caption = "Database Restore Canceled"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -