Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
IS THIS QUESTION NOT CLEAR??!!

for backup Db in sqlExpress 2008 i use code:

C#
strFileName = "BackupFile.bak";
try 
{     
    this.Cursor = Cursors.WaitCursor;     
    SqlCommand cmd = new SqlCommand();     
    SqlConnection.ClearAllPools();     
    cmd.Connection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirecto  ry|\\file.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");     
    
    cmd.Connection.Open();     
    string dbname = cmd.Connection.Database;     
    cmd.Connection.Close();     
    string query = "BACKUP DATABASE [" + dbname + "] TO DISK ='" + Masir.ToString().Trim() + "\\" + strFileName + "'";     
    cmd.Connection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirecto ry|\\file.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;");     
    
    cmd.Connection.Open();     
    cmd.CommandText = query;     
    cmd.ExecuteNonQuery();     
    cmd.Connection.Close();     
    this.Cursor = Cursors.Default;
    MessageBox.Show("backup successful", "backup", MessageBoxButtons.OK, MessageBoxIcon.Information); 
}
catch (Exception ex) 
{     
    MessageBox.Show("Error Occurd : " + ex.Message); 
}
//end code

Here is Error:
Invalid column name 'is_compressed'. Invalid column name 'compressed_backup_size'. Could not insert a backup or restore history/detail record in the msdb database. This may indicate a problem with the msdb database. The backup/restore operation was still successful.

please help.thanks
Posted
v4
Comments
[no name] 2-Aug-13 20:55pm    
http://forums.asp.net/t/1576803.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900