Try:
Code:
' ********************************************************************************
' @file BackRest.bas
' @description Backup & Restore with long file names (with spaces)
' @copyright Copyright © SQLDev.Net 1991-2003 All rights reserved.
' @author [email protected]
' ********************************************************************************
' ********************************************************************************
' Add reference to Microsoft SQLDMO Object Library
' Located in C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQLDMO.dll
' ********************************************************************************
Private Sub BackupPubs()
On Error GoTo errHandler
Dim oSQLServer As New SQLDMO.SQLServer
Dim oBackup As New SQLDMO.Backup
oSQLServer.LoginSecure = True
oSQLServer.Connect "(local)"
oBackup.Database = "pubs"
oBackup.Files = "[C:\Program Files\Microsoft SQL Server\80\MSSQL\Backup\pubs.bak]"
oBackup.SQLBackup oSQLServer
Set oBackup = Nothing
oSQLServer.DisConnect
Set oSQLServer = Nothing
Exit Sub
errHandler:
Debug.Print Err.Number & " " & Err.Description
End Sub
Private Sub RestorePubs()
On Error GoTo errHandler
Dim oSQLServer As New SQLDMO.SQLServer
Dim oRestore As New SQLDMO.Restore
oSQLServer.LoginSecure = True
oSQLServer.Connect "(local)"
oRestore.Database = "pubs"
oRestore.Files = "[C:\Program Files\Microsoft SQL Server\80\MSSQL\Backup\pubs.bak]"
oRestore.SQLRestore oSQLServer
Set oRestore = Nothing
oSQLServer.DisConnect
Set oSQLServer = Nothing
Exit Sub
errHandler:
Debug.Print Err.Number & " " & Err.Description
End Sub