数据库

img iwebsms

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

发表于2004/9/28 19:16:00  1101人阅读

    '备份数据库

    '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
阅读全文
0 0

相关文章推荐

img
取 消
img