Prueba lo siguiente:
Con llamar a DB_Backup con los parametros correctos deberia servirte, suerte
'* * * * * * * * * * * * * *
'Passing Values
'* * * * * * * * * * * * * *
'nServer_Name = SQL server name
'nDB_Name = Database name
'nDB_Login = Login name
'nDB_Password = Password
'nBack_Dev =Backup device name
'nBack_Set = Backup set name
'nBack_Desc = Backup discription
'Backup device name has to be specified by the SQL ADMIN.
'Which comes under SQL Backup. The name you specified must
'be same as Passing value of backup device name.
'SQL ADMIN can only specify the device type(Tape, HD,...).
'* * * * * * * * * * * * * *
'* * * * * * * * * * * * * *
Option Explicit
Private oSQLServer As SQLDMO.SQLServer
Public Function DB_Backup(ByVal nServer_Name As String, _
ByVal nDB_Name As String, _
ByVal nDB_Login As String, ByVal nDB_Password As String, _
ByVal nBack_Dev As String, ByVal nBack_Set As String, _
ByVal nBack_Desc As String) As Boolean
' nServer_Name = SQL server name
' nDB_Name = Database name
' nDB_Login = Login name
' nDB_Password = Password
' nBack_Dev =Backup device name
' nBack_Set = Backup set name
' nBack_Desc = Backup discription
Dim oBackup As SQLDMO.Backup
Dim i As Integer
Dim swExist As Boolean
'On Error GoTo ErrorHandler
Set oBackup = CreateObject("SQLDMO.Backup")
If Connect_SQLDB(nServer_Name, nDB_Login, nDB_Password) Then
i = 1
Do
If oSQLServer.BackupDevices.Item(i).Name = nBack_Dev Then
swExist = True
End If
i = i + 1
Loop Until i > oSQLServer.BackupDevices.Count Or swExist = True
If Not swExist Then
Dim oDevice As New SQLDMO.BackupDevice
oDevice.Name = nBack_Dev
oDevice.Type = SQLDMODevice_DiskDump
oDevice.PhysicalLocation = IIf(Right(App.Path, 1) = "\", App.Path & nBack_Dev & ".bck", App.Path & "\" & nBack_Dev & ".bck")
oSQLServer.BackupDevices.Add oDevice
End If
oBackup.Devices = "[" & nBack_Dev & "]"
oBackup.Database = nDB_Name
oBackup.BackupSetName = nBack_Set
oBackup.BackupSetDescription = nBack_Desc
oBackup.SQLBackup oSQLServer
oSQLServer.DisConnect
DB_Backup = True
End If
Exit Function
ErrorHandler:
DB_Backup = False
End Function
Private Function Connect_SQLDB(ByVal nServer_Name As String, _
ByVal nDB_Login As String, _
ByVal nDB_Password As String) As Boolean
' nServer_Name = SQL server name
' nDB_Login = Login name
' nDB_Password = Password
Set oSQLServer = CreateObject("SQLDMO.SQLServer")
On Error GoTo ErrorHandler
Connect_SQLDB = False
oSQLServer.Connect nServer_Name, nDB_Login, nDB_Password
Connect_SQLDB = True
Exit Function
ErrorHandler:
oSQLServer.DisConnect
Connect_SQLDB = False
End Function