📄 frmbackup.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form frmbackup
Caption = "备份与恢复"
ClientHeight = 5085
ClientLeft = 60
ClientTop = 450
ClientWidth = 3735
LinkTopic = "form2"
ScaleHeight = 5085
ScaleWidth = 3735
StartUpPosition = 3 '窗口缺省
Begin MSComDlg.CommonDialog CommonDialog1
Left = 3120
Top = 1920
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command3
Caption = "退出"
Height = 855
Left = 600
TabIndex = 2
Top = 3120
Width = 2295
End
Begin VB.CommandButton Command2
Caption = "备份"
Height = 855
Left = 600
TabIndex = 1
Top = 480
Width = 2295
End
Begin VB.CommandButton Command1
Caption = "恢复"
Height = 735
Left = 600
TabIndex = 0
Top = 1800
Width = 2295
End
End
Attribute VB_Name = "frmbackup"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command2_Click()
Dim sql As String
On Error GoTo errhandler
conn.Close
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=."
conn.Open
CommonDialog1.ShowSave
sql = "backup database book to disk='" & CommonDialog1.FileName & "'"
CommonDialog1.CancelError = True
conn.Execute (sql)
MsgBox "备份成功", vbOKOnly + vbExclamation, "恭喜"
conn.Close
Exit Sub
errhandler:
Exit Sub
End Sub
Private Sub Command1_Click()
Dim sql As String
On Error GoTo errhandler
conn.Close
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=."
conn.Open
CommonDialog1.ShowOpen
CommonDialog1.CancelError = True
sql = "restore database book from disk='" & CommonDialog1.FileName & "'"
conn.Execute (sql)
MsgBox "恢复成功", vbOKOnly + vbExclamation, "恭喜"
conn.Close
Exit Sub
errhandler:
Exit Sub
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
CommonDialog1.Filter = "备份文件(*.bak)"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -