📄 frmdbf.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form frmDbf
AutoRedraw = -1 'True
BackColor = &H80000004&
BorderStyle = 1 'Fixed Single
Caption = "Database Backup and Restore"
ClientHeight = 5475
ClientLeft = 45
ClientTop = 330
ClientWidth = 9675
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 5475
ScaleWidth = 9675
Begin VB.PictureBox Picture3
Height = 1815
Left = -120
Picture = "frmDbf.frx":0000
ScaleHeight = 1755
ScaleWidth = 11955
TabIndex = 9
Top = -120
Width = 12015
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "BackUp Management Form"
BeginProperty Font
Name = "Verdana"
Size = 24
Charset = 0
Weight = 700
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000006&
Height = 570
Left = 600
TabIndex = 10
Top = 240
Width = 7185
End
End
Begin VB.Frame Frame1
BackColor = &H80000004&
Caption = "Enter the following information:"
ForeColor = &H80000007&
Height = 2805
Left = 1440
TabIndex = 0
Top = 2040
Width = 6765
Begin MSComDlg.CommonDialog CC
Left = 5160
Top = 240
_ExtentX = 847
_ExtentY = 847
_Version = 393216
CancelError = -1 'True
DefaultExt = "*.bak"
DialogTitle = "Open Back Up Files"
Filter = "SQL Server backup Files(*.bak)|*.bak"
InitDir = "C:\"
End
Begin VB.CommandButton cmdOpen
Caption = ".."
Height = 315
Left = 5280
TabIndex = 8
Top = 840
Width = 315
End
Begin VB.CommandButton cmdBackUp
BackColor = &H8000000C&
Caption = "Start &Back up..."
Enabled = 0 'False
Height = 345
Left = 1560
TabIndex = 7
Top = 2040
Width = 1935
End
Begin VB.CommandButton cmdRestore
BackColor = &H8000000C&
Caption = "&Restore Now"
Enabled = 0 'False
Height = 345
Left = 3600
TabIndex = 6
Top = 2040
Width = 2175
End
Begin VB.TextBox txtPath
Enabled = 0 'False
Height = 315
Left = 1680
TabIndex = 2
Top = 840
Width = 3375
End
Begin VB.TextBox txtDB
Enabled = 0 'False
Height = 315
Left = 1680
TabIndex = 1
Text = "InstituteSystem"
Top = 480
Width = 2505
End
Begin MSComctlLib.ProgressBar P1
Height = 285
Left = 1680
TabIndex = 5
Top = 1320
Width = 4215
_ExtentX = 7435
_ExtentY = 503
_Version = 393216
BorderStyle = 1
Appearance = 0
End
Begin VB.Label lblCommon
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "File Path:"
ForeColor = &H80000007&
Height = 255
Index = 0
Left = 360
TabIndex = 4
Top = 840
Width = 765
End
Begin VB.Label lblCommon
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "Database Name:"
ForeColor = &H80000007&
Height = 255
Index = 1
Left = 240
TabIndex = 3
Top = 510
Width = 1455
End
End
End
Attribute VB_Name = "frmDbf"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim MyServer As New SQLDMO.SQLServer
Dim WithEvents DbackUp As SQLDMO.Backup
Attribute DbackUp.VB_VarHelpID = -1
Dim WithEvents DRestore As SQLDMO.Restore
Attribute DRestore.VB_VarHelpID = -1
Private Sub cmdBackUp_Click()
On Error GoTo 1
MyServer.LoginSecure = True
MyServer.Connect ServerName
Set DbackUp = New SQLDMO.Backup
DbackUp.Database = txtDB.Text
DbackUp.Files = txtPath.Text
If Len(Dir(txtPath)) > 0 Then
Kill (txtPath.Text)
End If
'DbackUp.Action = SQLDMOBackup_Differential
DbackUp.SQLBackup MyServer
Set DbackUp = Nothing
Set MyServer = Nothing
Exit Sub
1:
MsgBox Err.Number & vbCrLf & Err.Description, vbInformation
End Sub
Private Sub Command1_Click()
End Sub
Private Sub cmdOpen_Click()
On Error GoTo 1
CC.ShowOpen
txtPath.Text = CC.FileName
Exit Sub
1:
Exit Sub
End Sub
Private Sub cmdRestore_Click()
MyServer.Connect ServerName, UserName, password
Set DRestore = New SQLDMO.Restore
DRestore.Database = txtDB.Text
DRestore.Files = txtPath.Text
'Drestore.Action =SQLDMORestore_Database
DRestore.SQLRestore MyServer
DRestore.SQLVerify MyServer
Set DbackUp = Nothing
Set MyServer = Nothing
End Sub
Private Sub DbackUp_Complete(ByVal Message As String)
MsgBox Message
P1.Value = 0
End Sub
Private Sub DbackUp_PercentComplete(ByVal Message As String, ByVal Percent As Long)
DoEvents
P1.Value = Percent
End Sub
Private Sub DRestore_Complete(ByVal Message As String)
MsgBox Message
P1.Value = 0
End Sub
Private Sub DRestore_PercentComplete(ByVal Message As String, ByVal Percent As Long)
P1.Value = Percent
End Sub
Private Sub Form_Load()
Dither Me
End Sub
Private Sub txtPath_Change()
If txtPath = "" Then
cmdBackUp.Enabled = False
Else
cmdBackUp.Enabled = True
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -