Public class form1 inherits system.windows.Forms.Form #Region "Windows Form Designer Generated Code" Public Sub New () MyBase.new () 'This call is required for the Windows Form Designer. InitializationComponent () 'Add any initialization End Sub' form rewriting to clean the component list after the initializationComponent () call. Protected Overloads Overrides Sub Dispose (ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose () End If End If MyBase.Dispose (disposing) End Sub 'Windows Form Designer Private components required As system.componentmodel.icontainer 'Note: The following procedure is required to use the Windows Form Designer to modify this process using the Windows Form Designer. 'Don't modify it using the code editor.
Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar Friend WithEvents Button1 As System.Windows.Forms.Button
False me.startPosition = system.windows.forms.formstartPosition.CenterScreen Me.ResumeLayout (false) End Sub #end region 'This is not processed by the attribute because it is troubles that PUBLIC SA AS STRING PUBLIC PASSERD AS STRING PUBLIC FILE As String Public database As String Public sqlserver As String Public flag As Boolean = True Private WithEvents PBackup As New SQLDMO.Backup () Private WithEvents oRestore As New SQLDMO.Restore () 'Property SQLServerName () As String' Get 'Return sqlserver' End Get 'Set (ByVal Value As String)' sqlserver = Value 'End Set' End Property 'backup Public Function bACKUP (ByVal DATABASENAME As String, ByVal SQLServe As String, ByVal ROLE As String, ByVal PASSWORD As String, ByVal backfilename As String) Me.ProgressBar1.Value = 0 me.backcolor = system.drawing.color.royalblue me.button1.text = "Backup" me.show () on Error Goto Errhandler Dim S QLSER As New SQLDMO.SQLServer SQLSER.Connect (SQLServe, ROLE, PASSWORD) PBackup.Database = DATABASENAME System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor PBackup.Files = backfilename PBackup.SQLBackup (SQLSER ) Sqlser.disconnect () SQLSER = Nothing system.windows.Forms.cursor.current = system.windows.Forms.cursors.default exit function errhandler: msgbox ("Backup failed, please check if the source database exists, the role permission is enough or Whether the SQL Server service is opened "& Chr (13) &" information: "& Err.Description) Resume next end function '
Recovery Public Function RSTORE (ByVal DATABASENAME As String, ByVal SQLServe As String, ByVal ROLE As String, ByVal PASSWORD As String, ByVal restfilename As String) Me.ProgressBar1.Value = 0 Me.BackColor = System.Drawing.Color.OliveDrab Me. Button1.Text = "recovery" Me.Show () On Error GoTo ErrHandler Dim SQLSER As New SQLDMO.SQLServer SQLSER.Connect (SQLServe, ROLE, PASSWORD) oRestore.Database = DATABASENAME oRestore.Files = restfilename System.Windows.Forms.Cursor .Current = System.Windows.Forms.Cursors.WaitCursor oRestore.SQLRestore (SQLSER) System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default SQLSER.DisConnect () SQLSER = Nothing Exit Function ErrHandler: MsgBox ("Recovery failed, please check if the recovery database exists, the role permission is enough or whether the SQL Server service is opened" & chr (13) & "information:" & Err.Description) Resume Next End Function Private Sub PBackup_complete (Byval Message As String) HA ndles PBackup.Complete Me.ProgressBar1.Value = 100 PBackup = Nothing Me.oRestore = Nothing Me.Close () End Sub Private Sub PBackup_PercentComplete (ByVal Message As String, ByVal Percent As Integer) Handles PBackup.PercentComplete Me.BackColor = System. Drawing.color.royalblue me.progressbar1.value = percent if percent = 100 Then me.progressbar1.value = 100 PBackup = Nothing me.oRestore =