📄 datafrom.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form DataFrom
Caption = "数据备份&恢复"
ClientHeight = 5100
ClientLeft = 60
ClientTop = 420
ClientWidth = 7305
LinkTopic = "Form1"
ScaleHeight = 5100
ScaleWidth = 7305
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command6
Caption = "返回"
Height = 375
Left = 4200
TabIndex = 8
Top = 4200
Width = 1095
End
Begin VB.CommandButton Command4
Caption = "退出"
Height = 375
Left = 5400
TabIndex = 7
Top = 4200
Width = 1095
End
Begin MSComDlg.CommonDialog CommonDialog2
Left = 1080
Top = 4680
_ExtentX = 847
_ExtentY = 847
_Version = 393216
FileName = "*.bak"
Filter = "备份文件(*.bak)|*.bak"
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 600
Top = 4680
_ExtentX = 847
_ExtentY = 847
_Version = 393216
FileName = "*.bak"
Filter = "备份文件(*.bak)|*.bak"
End
Begin VB.Frame Frame2
Caption = "还原企业管理系统:"
Height = 1575
Left = 600
TabIndex = 1
Top = 2400
Width = 6015
Begin VB.TextBox Text2
Height = 270
Left = 1800
TabIndex = 10
Top = 412
Width = 2895
End
Begin VB.CommandButton Command3
Caption = "浏览"
Height = 375
Left = 4800
TabIndex = 9
Top = 360
Width = 1095
End
Begin VB.CommandButton Command5
Caption = "还原"
Height = 375
Left = 4800
TabIndex = 6
Top = 960
Width = 1095
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "还原的备份文件:"
Height = 180
Left = 240
TabIndex = 11
Top = 457
Width = 1350
End
End
Begin VB.Frame Frame1
Caption = "备份企业管理系统:"
Height = 1575
Left = 600
TabIndex = 0
Top = 480
Width = 6015
Begin VB.CommandButton Command2
Caption = "备份"
Height = 390
Left = 4800
TabIndex = 5
Top = 960
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "浏览"
Height = 390
Left = 4800
TabIndex = 4
Top = 390
Width = 1095
End
Begin VB.TextBox Text1
Height = 270
Left = 1800
TabIndex = 3
Top = 450
Width = 2895
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "备份文件库路径:"
Height = 180
Left = 240
TabIndex = 2
Top = 495
Width = 1350
End
End
End
Attribute VB_Name = "DataFrom"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
On Error Resume Next
CommonDialog1.CancelError = True
CommonDialog1.ShowOpen
If Err = cdlCancel Then Exit Sub
Text1.Text = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
'连接数据库
Set Ado_Conn = New ADODB.Connection
Set Ado_RS = New ADODB.Recordset
str_CS = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ManageSystem"
str_RS = "select * from BaseTable where BID='" & Trim(Text1.Text) & "'"
SqlConnect Ado_Conn, Ado_RS, str_CS, str_RS
Ado_Conn.Execute "backup database ManageSystem to disk='" & Text1.Text & "'"
MsgBox "已保存到 " & Text1.Text & "。备份成功。", vbInformation, "备份成功"
SqlDisConnect Ado_RS
End Sub
Private Sub Command3_Click()
On Error Resume Next
CommonDialog2.CancelError = True
CommonDialog2.ShowOpen
If Err = cdlCancel Then Exit Sub
Text2.Text = CommonDialog2.FileName
End Sub
Private Sub Command4_Click()
SureExit
End Sub
Private Sub Command5_Click()
'连接数据库
Set Ado_Conn = New ADODB.Connection
Set Ado_RS = New ADODB.Recordset
str_CS = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ManageSystem"
str_RS = "select * from BaseTable where BID='" & Trim(Text1.Text) & "'"
SqlConnect Ado_Conn, Ado_RS, str_CS, str_RS
Ado_Conn.Execute "use master"
Ado_Conn.Execute "restore database ManageSystem from disk='" & Text2.Text & "'"
MsgBox "已恢复数据库。", vbInformation, "恢复成功"
SqlDisConnect Ado_RS
End Sub
Private Sub Command6_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -