Backup and Restore SQL database with vb.net
I have the following code:
This is not working. I am getting the following error:
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"
.Files = BACKUPFILE
.Database = DATABASE
.BackupSetName = "VoiceNet"
.BackupSetDescription = "Backup from VB.NET application"
.oSQLServer.Connect("NINEL-D246655F1", "timecontroluser", "timecontroluser")
"Public member 'oSQLServer' on type 'BackupClass' not found."
Does anyone know how to accomplish this?
Let IntelliSense help you: Inside your "With oBackup" block, press the period (.) key, and look at the dropdown list of properties and methods. You'll find that there is not one called "oSQLServer," which is why you're getting the error. I suspect that you intend to call oSQLServer.Connect directly, without the preceding period.
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
I got that working. I needed to move the oSQLServer.Connect("NINEL-D246655F1", "timecontroluser", "timecontroluser") out of the with statement.
I am now having an issue with the restore.
I have a db called Voicenet_Template (this is the db I backed up).
Now I'd like to restore the backup, but with a different database name and therefore different log and mdf files.
The backup file is for db Voicenet_Template which has log(Voicenet_Template_log.ldf) and data files (Voicenet_Template.mdf).
The new db should be Voicenet_ABC and log and mdf files Voicenet_ABC_log.ldf and Voicenet_ABC.mdf
Do you know how I can do this?
Last Post: 03-31-2003, 11:23 PM
By Jeremiahb in forum Database
Last Post: 01-10-2002, 06:47 AM
By impulse24 in forum Database
Last Post: 01-02-2002, 07:36 PM
By Bill Lunney in forum Database
Last Post: 09-15-2000, 05:08 AM
By Manuel De Leon in forum Database
Last Post: 05-31-2000, 10:53 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL