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.Incremental = False
sqlBackup.ExpirationDate = DateTime.Now.AddDays(3)
sqlBackup.LogTruncation = BackupTruncateLogType.Truncate
sqlBackup.FormatMedia = False

Thank you all in advance for your support

I need to backup the sql server 2000 database in code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.