Backup failed for Server '\\.\pipe\6754F9F4-3FC4-42\tsql\query'. this version is not supported
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using Microsoft.SqlServer.Management; using Microsoft.SqlServer.Management.Smo; using System.Data; using System.Data.SqlClient; using System.Collections.Specialized; using System.IO; using Microsoft.SqlServer.Management.Common; namespace ChequeText { class BackupRestore : DBConnection { /// <summary> /// Backup the database /// </summary> internal void TakeBackUp() { //if(MessageConfirmation.MessageShowYesNo("Do you want to take back up?")) // if (MessageBox.Show("Do you want to take back up?", "My Soft", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) if (MessageBox.Show("Do you want to take back up?", "Bank", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } string DBName = sqlcon.Database; ; string[] arr = DBName.Split('\\'); DBName = arr[arr.Length - 1].Replace(".MDF", ""); string DBFolder = arr[arr.Length - 2]; ServerConnection srvConn = new ServerConnection(sqlcon); SaveFileDialog saveBackupDialog = new SaveFileDialog(); Server srvSql = new Server(srvConn); string path = Application.StartupPath + @"\Data\DBBankCheque.mdf"; srvSql = new Server(srvConn); DateTime BackupDate = DateTime.Now; string BakDt = BackupDate.ToString("ddMMyyyhhmmss"); string FName = "Bank---" + DBFolder + "-" + BakDt + ".bak"; saveBackupDialog.FileName = FName; if (saveBackupDialog.ShowDialog() == DialogResult.OK) { Backup bkpDatabase = new Backup(); bkpDatabase.Action = BackupActionType.Database; bkpDatabase.Database = path; BackupDeviceItem bkpDevice = new BackupDeviceItem(saveBackupDialog.FileName, DeviceType.File); bkpDatabase.Devices.Add(bkpDevice); try { bkpDatabase.SqlBackup(srvSql); MessageBox.Show("The backup of database completed successfully ", "Bank", MessageBoxButtons.OK, MessageBoxIcon.Information); // MessageBoxes.messageBoxShow("The backup of database completed successfully"); } catch (Exception ex) { msgBox.Commen(ex.ToString() ); // MessageBox.Show("Backup failed for Server . (Microsoft.SqlServer.Smo)", "Bank Software", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { sqlcon.Close(); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)