Backup and Restore SQL database with vb.net

ninel

Active member
Joined
Mar 23, 2005
Messages
32
Location
Land O Lakes, Florida
Programming Experience
3-5
I have the following code:
VB.NET:
Dim oSQLServer As New SQLDMO.SQLServer
Dim oBackup As New SQLDMO.Backup
Dim oRestore As New SQLDMO.Restore
Dim BACKUPFILE As String
Dim DATABASE As String
BACKUPFILE = "C:\VoicenetSQL\project\tampa\Politic\" & ProjectFolder & "\VoiceNet_TemplateBackup.bkp"
       
DATABASE = "VoiceNet_at0000"
With oBackup
            .Files = BACKUPFILE
            .Database = DATABASE
            .BackupSetName = "VoiceNet"
            .BackupSetDescription = "Backup from VB.NET application"
            .oSQLServer.Connect("NINEL-D246655F1", "timecontroluser", "timecontroluser")
            .SQLBackup(oSQLServer)
        End With
        
        oSQLServer.DisConnect()
This is not working. I am getting the following error:
"Public member 'oSQLServer' on type 'BackupClass' not found."
Does anyone know how to accomplish this?
Thanks,
Ninel
 
I assume that because of the error he already has added the reference. More likely to be a typo in the article that that code was pasted in from.
Just a guess, but i think that this line...

VB.NET:
.oSQLServer.Connect("NINEL-D246655F1", "timecontroluser", "timecontroluser")
should read..

VB.NET:
.SQLServer.Connect("NINEL-D246655F1", "timecontroluser", "timecontroluser")
 
Back
Top