title: Detach and take a copy database and attach it to SQL Server
body: <p>I am trying to copy a database file using file management concept in vb.</p>
  
  <p>My code is:</p>
  
  <pre><code>IO.File.Copy(MukilCommon.APP_PATH &amp; "\" &amp; CurrentDbName &amp; ".mdf", MukilCommon.APP_PATH &amp; "\" &amp; CurrentDbName &amp; "_" &amp; yearStr &amp; ".mdf")
  IO.File.Copy(MukilCommon.APP_PATH &amp; "\" &amp; CurrentDbName &amp; ".ldf", MukilCommon.APP_PATH &amp; "\" &amp; CurrentDbName &amp; "_" &amp; yearStr &amp; ".ldf")
  </code></pre>
  
  <p>My code is copied a database from new database on <code>e:</code>, like this:</p>
  
  <pre><code> sample.mdf
   sample.ldf
   sample_2016.mdf
   sample_2016.ldf
  </code></pre>
  
  <p>I used this code for attach my copied database in SQL Server.</p>
  
  <pre><code>  db1.Execute("EXEC sp_attach_db @dbname = '" &amp; CurrentDbName &amp; "_" &amp; yearStr &amp; "', @filename1 = '" &amp; MukilCommon.APP_PATH &amp; "\" &amp; CurrentDbName &amp; "_" &amp; yearStr &amp; ".mdf', @filename2 = '" &amp; MukilCommon.APP_PATH &amp; "\" &amp; CurrentDbName &amp; "_" &amp; yearStr &amp; ".ldf'")
  </code></pre>
  
  <p>But I get this message.</p>
  
  <blockquote>
    <p>Can't attach a file name, "sample" database is already exists in SQL Server.</p>
  </blockquote>
  
  <p>Actually the copied file has try to attached on original database. How to I attach this database?   </p>