ASP.NET or VB.NET development automatic backup database application

xiaoxiao2021-03-06  88

'backup database

'BackupDataName data inventory absolute path

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 the Conn.Open ()

Try

Cmd.executenonquery ()

Backupdata = ""

Catch exSql as sqlexception

IF exSql.number = 3201 THEN

Backupdata = "Please enter the storage path of the backup file correctly!"

Else

Backupdata = exSql.Message

END IF

Catch exception

Backupdata = ex.Message

END TRY

Cmd.connection.close ()

Cmd.dispose ()

Conn.dispose ()

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-123104.html

New Post(0)