I'm using the following code to back up a SQL Database :
void BackupDatabase(string sConnect, string dbName, string backUpPath)
{
using (SqlConnection cnn = new SqlConnection(sConnect))
{
cnn.Open();
dbName = cnn.Database.ToString();
ServerConnection sc = new ServerConnection(cnn);
Server sv = new Server(sc);
// Create backup device item for the backup
BackupDeviceItem bdi = new BackupDeviceItem(backUpPath, DeviceType.File);
// Create the backup informaton
Microsoft.SqlServer.Management.Smo.Backup bk = new Backup();
bk.PercentComplete += new PercentCompleteEventHandler(percentComplete);
bk.Devices.Add(bdi);
bk.Action = BackupActionType.Database;
bk.PercentCompleteNotification = 1;
bk.BackupSetDescription = dbName;
bk.BackupSetName = dbName;
bk.Database = dbName;
//bk.ExpirationDate = DateTime.Now.AddDays(30);
bk.LogTruncation = BackupTruncateLogType.Truncate;
bk.FormatMedia = false;
bk.Initialize = true;
bk.Checksum = true;
bk.ContinueAfterError = true;
bk.Incremental = false;
// Run the backup
bk.SqlBackup(sv);
}
}
In my system (Win7 x64) it works fine but in destination system (WinXP SP3 x86) I receive the below error :
How can I fix it ?
Thanks.