打印本文 打印本文 关闭窗口 关闭窗口
VB.NET DMO SQL SERVER备份恢复
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2860  更新时间:2007/11/14 12:53:57  文章录入:mintao  责任编辑:mintao
.Button1.Text = "恢复"
        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("恢复失败,请检查恢复数据库是否存在、角色权限是否足够或SQL SERVER服务是否被打开" & Chr(13) & "信息:" & Err.Description)
        Resume Next
    End Function

 

 

 

 


    Private Sub PBackup_Complete(ByVal Message As String) Handles 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 = Nothing
            Me.Close()

        End If
    End Sub
    Private Sub oRestore_Complete(ByVal Message As String) Handles oRestore.Complete

        Me.ProgressBar1.Value = 100
        PBackup = Nothing
        Me.oRestore = Nothing
        Me.Close()
    End Sub
    Private Sub oRestore_PercentComplete(ByVal Message As String, ByVal Percent As Integer) Handles oRestore.PercentComplete
        Me.BackColor = System.Drawing.Color.OliveDrab

        Me.ProgressBar1.Value = Percent
        If Percent = 100 Then

            Me.ProgressBar1.Value = 100
            PBackup = Nothing
            Me.oRestore = Nothing
            Me.Close()
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If flag = True Then

            Me.BACKUP(Me.database, Me.sqlserver, Me.sa, Me.passerd, Me.file)

        Else
            Me.RSTORE(Me.database, Me.sqlserver, Me.sa, Me.passerd, Me.file)

        End If

    End Sub

 


End Class

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口