[dba-SQLServer]SQL-DMO backup remote database

Elizabeth ecarey at myway.com
Thu Apr 24 16:26:27 CDT 2003


We do not have backup operator rights - nor would her PC allow me to connect.  I did try sending the file to a mapped drive that we both have - and also using an absolute address - those attempts gave me an error.

Here's the code.  I have 2 global variables declared - one to save the database name being backed up (we have several) and the other to keep track of which backup in the sequence (5) to do.

This is the code that does the business...

Public Sub BackupDatabase()
Dim oBackup As New SQLDMO.Backup
Dim oServer As New SQLDMO.SQLServer

oServer.LoginSecure = False
oServer.LoginTimeout = 60
oServer.Connect "(local)", "sa", ""
oBackup.Database = gstrDBName
oBackup.Files = "C:\Temp\" & gstrDBName & gnFileNumber & ".bak"
oBackup.SQLBackup oServer

Set oBackup = Nothing
oServer.Disconnect
Set oServer = Nothing

End Sub

Elizabeth


_______________________________________________
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com


More information about the dba-SQLServer mailing list