title: Do I have to use attach connection string whenever I connect to a SQL Server database?
body: <p>I am new to SQL Server. I created a C# application which uses a SQL Server database (automatic attach database) to read/store data using the following connection string:</p>
  
  <pre><code>SqlConnection cn = new SqlConnection(@"Data Source=localhost; AttachDbFilename=E:\DB\myDB.mdf; trusted_connection=yes")
  </code></pre>
  
  <p>Then I deployed my application into <code>exe</code> file. I went to another PC and installed SQL Server and installed my application on it. Now everything works fine but because I am new to SQL Server, I feel that I am attaching the database (<code>myDB</code>) in wrong way because it sounds like I attach this database every time I connect to SQL Server. </p>
  
  <p>I run my application for the first time and the database will be attached and next time I run my application it will be attached again (but it is already attached), am I wrong? </p>
  
  <p>My question is: why do I have to attach the database every time I connect to SQL Server using the above connection string? is there another way of attaching it only once? Thank you</p>