📄 frmdataback.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
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 FrmDataBack
BorderStyle = 1 'Fixed Single
Caption = "备份数据库"
ClientHeight = 3225
ClientLeft = 5565
ClientTop = 5310
ClientWidth = 4350
Icon = "FrmDataBack.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3225
ScaleWidth = 4350
Begin MSAdodcLib.Adodc AdoConn
Height = 330
Left = 150
Top = 0
Visible = 0 'False
Width = 1200
_ExtentX = 2117
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
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.TextBox Textmemo
Height = 975
Left = 480
TabIndex = 8
Top = 1320
Width = 3705
End
Begin VB.CommandButton Command3
Caption = "备份"
Enabled = 0 'False
Height = 330
Left = 3330
TabIndex = 5
Top = 2340
Width = 825
End
Begin MSComDlg.CommonDialog CmDlg
Left = 2700
Top = 30
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command2
Caption = "..."
Height = 255
Left = 3735
TabIndex = 4
Top = 945
Width = 435
End
Begin VB.TextBox Text1
Height = 330
Left = 180
TabIndex = 3
Top = 900
Width = 4020
End
Begin VB.Timer Timer1
Interval = 100
Left = 3930
Top = 60
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 330
Left = 3330
TabIndex = 0
Top = 2340
Visible = 0 'False
Width = 825
End
Begin MSComctlLib.ProgressBar ProgressBar1
Height = 285
Left = 180
TabIndex = 1
Top = 2340
Visible = 0 'False
Width = 3000
_ExtentX = 5292
_ExtentY = 503
_Version = 393216
Appearance = 1
Scrolling = 1
End
Begin VB.Label Label4
Caption = " 说 明"
Height = 825
Left = 210
TabIndex = 9
Top = 1320
Width = 255
End
Begin VB.Label Label3
Height = 525
Left = 180
TabIndex = 7
Top = 2700
Width = 4035
End
Begin VB.Label Label2
Caption = "请选择备份路径"
Height = 255
Left = 210
TabIndex = 6
Top = 660
Width = 2775
End
Begin VB.Label Label1
Caption = "请先关闭其他应用程序,在进行数据备份!"
Height = 240
Left = 225
TabIndex = 2
Top = 270
Width = 3570
End
End
Attribute VB_Name = "FrmDataBack"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Dim Done As Boolean
Dim isErr As Boolean
Dim sqlStr As String
Private Sub Command2_Click()
FrmDir.Show vbModal, Me
Text1.Text = SavePath
If SavePath <> "" Then
Command3.Enabled = True
Else
End If
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command3_Click()
On Error GoTo Err
ProgressBar1.Visible = True
Command3.Visible = False
Me.MousePointer = 11
SavePath = Text1.Text
SavePath = SavePath & "\mgydb.mdb-" & Date & ".bak"
' MsgBox SavePath
FileCopy App.Path & "\mgydb.mdb", SavePath
' MsgBox App.Path & "\mgydb.mdb"
sqlStr = "select * from recover"
AdoConn.RecordSource = sqlStr
AdoConn.Refresh
Dim mmText As String
mmText = Textmemo.Text
If mmText = "" Then mmText = "无"
' sqlStr = "insert into recover(DATETIME,DIRNAME,MEMO) values ('" & Date & "','" & mmText & "','" & mmText & "')"
' MsgBox sqlStr
' AdoConn.RecordSource = sqlStr
' AdoConn.Refresh
AdoConn.Recordset.AddNew
AdoConn.Recordset.Fields.Item(1).Value = Date & "-" & Time
AdoConn.Recordset.Fields.Item(2).Value = SavePath
AdoConn.Recordset.Fields.Item(3).Value = mmText
AdoConn.Recordset.Update
Me.MousePointer = 0
Done = True
'MsgBox "备份完成,被份文件保存在" & SavePath & "\mgydb.mdb-" & Date & "-bak.mdb", vbOKOnly, "提示"
Exit Sub
Err:
Me.MousePointer = 0
MsgBox "请关闭其他程序,再进行数据备份!", vbExclamation, "警告"
isErr = True
Command1.Value = True
End Sub
Private Sub Form_Load()
Done = False
isErr = False
AdoConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\mgydb.mdb;Persist Security Info=False"
AdoConn.CommandType = adCmdText
End Sub
Private Sub Text1_Change()
Command3.Visible = True
End Sub
Private Sub Timer1_Timer()
If isErr = True Then
ProgressBar1.Value = 1
Timer1.Enabled = False
Label3.Caption = "备份失败!"
Me.MousePointer = 0
End If
i = i + 1
ProgressBar1.Value = i
If Done = True Then
ProgressBar1.Value = 100
End If
If ProgressBar1.Value = 100 Then
Timer1.Enabled = False
Label3.Caption = "备份完成,备份文件保存在" & SavePath
ProgressBar1.Visible = False
Me.MousePointer = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -