title: How to create database backup, when DB not stored in Microsoft SQL Server?
body: <p>I am building a C# application with SQL Server 2008 R2 database which is stored in the <code>bin</code> folder of my project. I use Linq to Sql method to create the database and attach it to my project.</p>
  
  <p>The problem that I'm having is that when I'm trying to create a backup of my database. It throws an error saying</p>
  
  <blockquote>
    <p>Database (database_name) does not exist make sure the name is entered correctly. BACKUP DATABASE is terminating abnormally.</p>
  </blockquote>
  
  <p>Here is the code that i write on my button click event:</p>
  
  <pre><code>try
  {
      SaveFileDialog sd = new SaveFileDialog();
      sd.Filter = "SQL Server database backup files|*.bak";
      sd.Title = "Create Database Backup";
  
      if (sd.ShowDialog() == DialogResult.OK)
      {
          using (SqlConnection conn = new SqlConnection(connStr))
          {
              string sqlStmt=string.Format("BACKUP DATABASE &lt;database_name&gt; TO DISK='{0}'",sd.FileName);
  
              using (SqlCommand bu2 = new SqlCommand(sqlStmt, conn))
              {
                  conn.Open();
                  bu2.ExecuteNonQuery();
                  conn.Close();
  
                  MessageBox.Show("Backup Created Sucessfully");
              }
          }
      }
  }
  catch(Exception ex)
  {
      MessageBox.Show(ex.ToString());
  }
  </code></pre>
  
  <p>My Connection String:</p>
  
  <pre><code>string connStr = ConfigurationManager.ConnectionStrings["project_name.Properties.Settings.project‌​_nameConnectionString"].ConnectionString; 
  </code></pre>
  
  <p>and then from my app.config file </p>
  
  <pre><code>&lt;add name="project_name.Properties.Settings.project_nameConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database_name.mdf;Integrate‌​d Security=True;User Instance=True" providerName="System.Data.SqlClient" /&gt; 
  </code></pre>
  
  <p>so if any one have a solution to my problem that will be helpful.</p>