title: How to backup from .mdf database that created by VS
body: <p>I was created a .mdf database file with vs 2010. I can retrive and insert data into database bbut when i want to backup error was handled. that database not attach in Management Studio.</p>
  
  <p>my Code :</p>
  
  <pre><code>SqlConnection connect;
  connect = new SqlConnection(DAL.AccessLayerClass._connectionStr);
  connect.Open();
  SqlCommand command;
  command = new SqlCommand(@"backup database AGMDB to disk ='d:\svBackUp1.bak' with init,stats=10",connect);
  command.ExecuteNonQuery();
  connect.Close();
  MessageBox.Show("The support of the database was successfully performed", "Back", MessageBoxButtons.OK, MessageBoxIcon.Information);
  </code></pre>
  
  <p>my connection string:</p>
  
  <pre><code>string _connectionStr = "Data Source=.\\SQLEXPRESS; AttachDbFilename=" + System.Windows.Forms.Application.StartupPath + "\\Database\\AGMDB.mdf; Integrated Security=True; Connect Timeout=30; User Instance=True;";
  </code></pre>
  
  <p>and that error was occurs:</p>
  
  <pre><code>Could not locate entry in sysdatabases for database 'AGMDB'. No entry found with that name. Make sure that the name is entered correctly.
  BACKUP DATABASE is terminating abnormally.
  </code></pre>
  
  <p>how can i solve this error?
  Thanks</p>