Need help in creating backup/restore on database using SQL Server 2005 with VB6.0 code when the database is on the network.
Thank you for opening your own thread.:)
The attached file will help you in getting the backup sorted. You will however need to play with the code to suit your needs, getting the connection on the network, sorting sql user privileges etc.
The code is not by me, all credit to the developer.
Thank you for replying. I will try it right now.
Please help if you have a sample code using SQLDMO w/c creates *.bak file for data sql server 2005 database backup.
my code so far:
Public Function BackUpDatabase() As Boolean
Dim objBackup As New SQLDMO.Backup
Dim objServer As New SQLDMO.SQLServer
Dim objDevice As New SQLDMO.BackupDevice
objDevice.Type = SQLDMODevice_DiskDump
objDevice.Name = "SamplesDeviceBackup"
objDevice.PhysicalLocation = "C:\SAMPLEBACKUP.BAK"
objServer.Connect "[networkservername]", "[username]", "[password]"
objBackup.Action = SQLDMOBackup_Database
objBackup.Database = "SAMPLEDATABASE"
objBackup.Devices = "SamplesDeviceBackup"
objBackup.BackupSetDescription = "Sample Database Backup"
objBackup.BackupSetName = "Rex"
If Err.Number >= 0 Then
BackUpDatabase = True
BackUpDatabase = False
MsgBox "Error Occured : " & Err.Description & " " & Err.Number
: the problem is I cant find the .bak file on the drive specified. the backup is successfull as per message and the process took around 1-2 min after it gives out the message.
: the server is on the network. SQL Server 2005 and it is installed on Microsoft Windows Server 2003.
Please help your help on this...
Thank you in advance.
Do you have hidden files made visible? a .bak file is normally saved as a hidden file, hence you can't find it.
Otherwise, try and use some different code for the path to save to.:)
i've already tried to set the hidden files being shown already. But I will try to check the server if the its save in it.
Thank you again for replying.
No problem. Let me know how it went.