Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing SMO to backup SQL Server 2005 Database with C# Windows Forms Application, Back up failed
    primarykey
    data
    text
    <p>This is my code to back up my database I followed <a href="http://www.codeproject.com/KB/database/SQL_Server_2005_Database.aspx" rel="nofollow">this tutorial</a>, as you can see, the codes are identical. The error comes after I fill in the variables. The error I get is </p> <blockquote> <p>Backup failed for Server 'RITZEL-PC\SQLEXPRESS'.</p> </blockquote> <p><strong>Back up function:</strong></p> <pre><code> public void BackupDatabase(String databaseName, String userName, String password, String serverName, String destinationPath) { Backup sqlBackup = new Backup(); sqlBackup.Action = BackupActionType.Database; sqlBackup.BackupSetDescription = "ArchiveDataBase:" + DateTime.Now.ToShortDateString(); sqlBackup.BackupSetName = "Archive"; sqlBackup.Database = databaseName; BackupDeviceItem deviceItem = new BackupDeviceItem(destinationPath, DeviceType.File); ServerConnection connection = new ServerConnection(serverName, userName, password); Server sqlServer = new Server(connection); Database db = sqlServer.Databases[databaseName]; 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); } </code></pre> <p><strong>Button click</strong></p> <pre><code> private void BackUp_Btn_Click(object sender, EventArgs e) { String databaseName = @"D:\MY_THESIS\WORKING FILES\NNIT-RMS.mdf"; String userName = "NNIT-Admin"; String password = "password"; String serverName = @"RITZEL-PC\SQLEXPRESS"; String destinationPath = @"D:\"; BackupDatabase(databaseName,userName,password,serverName,destinationPath); } </code></pre> <p><strong>Database Information</strong> I am not allowed to post images yet but I have uploaded a screen shot. See here: <a href="http://img268.imageshack.us/img268/9250/sqlg.jpg" rel="nofollow">http://img268.imageshack.us/img268/9250/sqlg.jpg</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload