Dear All ,
I need to backup the sql server 2005 express database . It works fine if I make backup to specific folder"C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup" . But if I change the path to any other path . I got an error "Backup failed for Server 'server name'. "
my code is
Dim sqlBackup As New Backup()
sqlBackup.Action = BackupActionType.Database
sqlBackup.BackupSetDescription = "ArchiveDataBase:" + DateTime.Now.ToShortDateString()
sqlBackup.BackupSetName = "Archive"
sqlBackup.Database = "data"
Dim deviceItem As New BackupDeviceItem("C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\rft.bak", DeviceType.File)
Dim connection As New ServerConnection(".\SQLEXPRESS")
Dim sqlServer As New Server(connection)
Dim db As Database = sqlServer.Databases("RegServer")
sqlBackup.Initialize = True
sqlBackup.Checksum = True
sqlBackup.ContinueAfterError = True
sqlBackup.Devices.Add(deviceItem)
sqlBackup.Incremental = False
sqlBackup.ExpirationDate = DateTime.Now.AddDays(3)
sqlBackup.LogTruncation = BackupTruncateLogType.Truncate
sqlBackup.FormatMedia = False
sqlBackup.SqlBackup(sqlServer)
Thank you all in advance for your support