📄 frm_sjbfyhf.frm
字号:
TabIndex = 14
Top = 2160
Width = 2415
End
End
Begin VB.CommandButton Command4
Caption = "开始恢复"
Height = 375
Left = 3360
TabIndex = 10
Top = 3480
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "开始备份"
Height = 375
Left = 3360
TabIndex = 4
Top = 3480
Width = 1095
End
Begin VB.Frame Frame1
Height = 3375
Left = 2040
TabIndex = 1
Top = 0
Width = 3615
Begin MSComDlg.CommonDialog CommonDialog1
Left = 2520
Top = 1680
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command3
Caption = "<<"
Height = 310
Left = 3120
TabIndex = 7
Top = 2520
Width = 375
End
Begin MSComctlLib.ProgressBar ProgressBar1
Height = 300
Left = 120
TabIndex = 6
Top = 3000
Width = 3375
_ExtentX = 5953
_ExtentY = 529
_Version = 393216
Appearance = 1
End
Begin VB.TextBox Text1
Height = 300
Left = 120
TabIndex = 3
Top = 2520
Width = 3015
End
Begin VB.Label Label3
Caption = "单击“<<”图标按钮,选择一个要备份数据的文件夹,然后单击“开始备份”按钮开始备份数据"
Height = 615
Index = 1
Left = 480
TabIndex = 16
Top = 960
Width = 2775
End
Begin VB.Label Label1
Caption = "选择数据库备份路径"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C000C0&
Height = 375
Left = 120
TabIndex = 2
Top = 2160
Width = 2535
End
End
End
Attribute VB_Name = "frm_sjbfyhf"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim StrCnn As New Connection '定义连接
Dim key, list, sql As String '定义字符串变量
Private Sub Command1_Click()
Command1.Enabled = False
If Text1.Text = "" Then
MsgBox "请您选择数据库备份的路径!", 32, "人口信息管理系统"
Else
Dim connter As Integer
Dim sql, workarea(15) As String
ProgressBar1.Visible = True
ProgressBar1.Max = UBound(workarea)
ProgressBar1.Value = ProgressBar1.Min
For connter = LBound(workarea) To UBound(workarea)
workarea(connter) = "initial value" & connter
ProgressBar1.Value = connter
StrCnn.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=Backup"
sql = "backup DATABASE Data_RKGL TO disk='" & Text1.Text & "'"
StrCnn.Execute (sql) '执行SQL语句
StrCnn.Close
Next connter
ProgressBar1.Value = ProgressBar1.Min
MsgBox "数据库备份成功!"
Command1.Enabled = True
End If
frm_main.Text1.Text = Text3.Text
frm_main.Check1.Value = Check1.Value
frm_main.Check2.Value = Check2.Value
frm_main.Check3.Value = Check3.Value
frm_main.Check4.Value = Check4.Value
frm_main.Check5.Value = Check5.Value
frm_main.Check6.Value = Check6.Value
frm_main.Check7.Value = Check7.Value
frm_main.Check8.Value = Check8.Value
frm_main.Check9.Value = Check9.Value
frm_main.Check10.Value = Check10.Value
frm_main.Check11.Value = Check11.Value
frm_main.Check12.Value = Check12.Value
frm_main.Check13.Value = Check13.Value
frm_main.Check14.Value = Check14.Value
frm_main.Check15.Value = Check15.Value
frm_main.Check16.Value = Check16.Value
End Sub
Private Sub Command2_Click()
frm_main.Text1.Text = Text3.Text
frm_main.Check1.Value = Check1.Value
frm_main.Check2.Value = Check2.Value
frm_main.Check3.Value = Check3.Value
frm_main.Check4.Value = Check4.Value
frm_main.Check5.Value = Check5.Value
frm_main.Check6.Value = Check6.Value
frm_main.Check7.Value = Check7.Value
frm_main.Check8.Value = Check8.Value
frm_main.Check9.Value = Check9.Value
frm_main.Check10.Value = Check10.Value
frm_main.Check11.Value = Check11.Value
frm_main.Check12.Value = Check12.Value
frm_main.Check13.Value = Check13.Value
frm_main.Check14.Value = Check14.Value
frm_main.Check15.Value = Check15.Value
frm_main.Check16.Value = Check16.Value
Unload Me
frm_main.Show
End Sub
Private Sub Command3_Click()
CommonDialog1.Filter = "文本文件(*.txt)|*.txt|ALL File(*.*)|*.*"
CommonDialog1.ShowSave
Text1.Text = CommonDialog1.FileName
End Sub
Private Sub Command4_Click()
Command4.Enabled = False
If Text2.Text = "" Then
MsgBox "请您选择数据库恢复的路径!", 32, "人口信息管理系统"
Else
Dim connter As Integer
Dim sql, workarea(15) As String
ProgressBar2.Visible = True
ProgressBar2.Max = UBound(workarea)
ProgressBar2.Value = ProgressBar1.Min
For connter = LBound(workarea) To UBound(workarea)
workarea(connter) = "initial value" & connter
ProgressBar2.Value = connter
StrCnn.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=Backup"
sql = "RESTORE DATABASE Data_RKGL from disk='" & Text2.Text & "'"
StrCnn.Execute (sql) '执行SQL语句
StrCnn.Close
Next connter
ProgressBar2.Value = ProgressBar2.Min
MsgBox "数据库恢复成功!"
End If
frm_main.Text1.Text = Text3.Text
frm_main.Check1.Value = Check1.Value
frm_main.Check2.Value = Check2.Value
frm_main.Check3.Value = Check3.Value
frm_main.Check4.Value = Check4.Value
frm_main.Check5.Value = Check5.Value
frm_main.Check6.Value = Check6.Value
frm_main.Check7.Value = Check7.Value
frm_main.Check8.Value = Check8.Value
frm_main.Check9.Value = Check9.Value
frm_main.Check10.Value = Check10.Value
frm_main.Check11.Value = Check11.Value
frm_main.Check12.Value = Check12.Value
frm_main.Check13.Value = Check13.Value
frm_main.Check14.Value = Check14.Value
frm_main.Check15.Value = Check15.Value
frm_main.Check16.Value = Check16.Value
End Sub
Private Sub Command5_Click()
CommonDialog2.Filter = "文本文件(*.txt)|*.txt|ALL File(*.*)|*.*"
CommonDialog2.ShowOpen
Text2.Text = CommonDialog2.FileName
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Text3.Text = frm_main.Text1.Text
Check1.Value = frm_main.Check1.Value
Check2.Value = frm_main.Check2.Value
Check3.Value = frm_main.Check3.Value
Check4.Value = frm_main.Check4.Value
Check5.Value = frm_main.Check5.Value
Check6.Value = frm_main.Check6.Value
Check7.Value = frm_main.Check7.Value
Check8.Value = frm_main.Check8.Value
Check9.Value = frm_main.Check9.Value
Check10.Value = frm_main.Check10.Value
Check11.Value = frm_main.Check11.Value
Check12.Value = frm_main.Check12.Value
Check13.Value = frm_main.Check13.Value
Check14.Value = frm_main.Check14.Value
Check15.Value = frm_main.Check15.Value
Check16.Value = frm_main.Check16.Value
Unload frm_main
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -