-
Backup and Restore SQL database with vb.net
I have the following code:
Code:
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
-
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.
Phil Weber
http://www.philweber.com
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?
Thanks,
Ninel
Similar Threads
-
Replies: 0
Last Post: 03-31-2003, 10:23 PM
-
By Jeremiahb in forum Database
Replies: 2
Last Post: 01-10-2002, 05:47 AM
-
By impulse24 in forum Database
Replies: 0
Last Post: 01-02-2002, 06:36 PM
-
By Bill Lunney in forum Database
Replies: 2
Last Post: 09-15-2000, 04:08 AM
-
By Manuel De Leon in forum Database
Replies: 2
Last Post: 05-31-2000, 09:53 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks