ASP.NET或者VB.NET开发自动备份数据库应用程序

类别:.NET开发 点击:0 评论:0 推荐:

    '备份数据库

    'BackupDataName数据库存放的绝对路径

    Function BackUpData(ByVal BackupDataName As String) As String

        Dim Conn As New SqlClient.SqlConnection(ModConn.GetConn)

        Dim mySelectQuery As String = "Backup database popcrm to DISK ='" & BackupDataName & "'"

        Dim myReader As SqlClient.SqlDataReader

        Dim Cmd As New SqlCommand(mySelectQuery, Conn)

        If Conn.State = ConnectionState.Closed Then Conn.Open()

        Try

            Cmd.ExecuteNonQuery()

            BackUpData = ""

        Catch ExSQL As SqlException

            If ExSQL.Number = 3201 Then

                BackUpData = "请正确输入备份文件的存放路径!"

            Else

                BackUpData = ExSQL.Message

            End If

        Catch Ex As Exception

            BackUpData = Ex.Message

        End Try

        Cmd.Connection.Close()

        Cmd.Dispose()

        Conn.Dispose()

    End Function

本文地址:http://com.8s8s.com/it/it43883.htm