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

发表于:2007-06-30来源:作者:点击数: 标签:
@#备份 数据库 @#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 =@# Back
@#备份数据库

@#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://www.ltesting.net