Click here to Skip to main content
15,891,597 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have a Windows Application developed in VB.NET 2005, I am using Database as Sql Server 2000.

In my application, i have a Database Backup option has the Following Code,

                Dim conn As New ServerConnection(server, uid, pwd)
                Dim oSQLServer As New Server(conn) '--create the SMO server object using connection
                SaveFileDialog1.FileName = db + ".bak"
                SaveFileDialog1.ShowDialog()
                Dim s As String
                s = SaveFileDialog1.FileName
                Dim bkDevItem As New BackupDeviceItem(s, DeviceType.File) ' -- create SMO.Backupdevice object
                oBackup = New Backup()
                With oBackup ' Set the backup object property
                    .Action = BackupActionType.Database
                    .Database = db
                    .Devices.Add(bkDevItem)
                    .Initialize = True
                    .Checksum = True
                    .ContinueAfterError = True
                    .Incremental = False
                    .LogTruncation = BackupTruncateLogType.Truncate
                    .SqlBackup(oSQLServer) ' backup SQL database
                End With</pre>

It's working Fine, but when i am running from client machine the it shows the error Message 'Backup Failed for the Server XXXXXXX'

I was changed the Connection string needed server.

Any Suggestion would be Helpful.

Thanks
Posted

My be the user on client machine does not have permissions to create backup file?
 
Share this answer
 
Comments
Shanmugam Vasu 7-Nov-12 1:51am    
sorry for my late reply, I am confused with Permission. Permisson from my application or Permission from System Securities.
Maybe your problem is with bkDevItem which is a local path of the client machine.
When you backup a sql database, the device path should be one from the server machine.
For test purposes, change s = SaveFileDialog1.Filename to s = "c:\someofolderYouCreatedAtServer\yourbackupfile.bak"
 
Share this answer
 
v3
Comments
Shanmugam Vasu 7-Nov-12 1:55am    
sorry for my late reply, yes backup is creating on the server when we give the static path(Server Path). Can we create a backup file in client machine?
Raimis9 7-Nov-12 2:25am    
The backup folder on client machine must be shared. You should use UNC path for backup, for example: \\CLIENTPC\SHARE\db.bak .
_Vitor Garcia_ 7-Nov-12 5:26am    
right ! It was not clear to me on the initial question.
There are 2 thing i guess you should have in mind :
1. You should make sure that SQL Server service account has read and write priviledgeon the UNC path.
2. Backup up to UNC via Management studio UI is not supported. (this doesn't apply here, just as reminder)
Shanmugam Vasu 7-Nov-12 2:56am    
Thanks for your Quick Response. i am working with your suggestion. i will reply soon.
Shanmugam Vasu 15-Nov-12 3:12am    
Thanks., Backup is creating on the Shared Folder

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900