title: How to deploy or publish Windows app with SQL Server database
body: <p>I have developed a C# application with a SQL Server database. When I try to publish the application to test it >> it works correctly on my machine (that include the database in SQL Server data folder) >> but when I move that published app to another machine it doesn't work.</p>
  
  <p>I want to know the simplest way to deploy the project with its database together </p>
  
  <p>I am using this connection string in my <code>app.config</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;connectionStrings&gt;
      &lt;add name="cs" 
           providerName="System.Data.ProviderName" 
           connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\KBank.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" /&gt;
    &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>What should I do in order to place the database with the deployed app and dynamically modify the connection string  for the database in <code>app.config</code>?</p>
  
  <p>the exception shown when i open the project on the users machines says:</p>
  
  <blockquote>
    <p>An Attempet to Attach an auto-named database for file C:\Program
    Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\KBank.mdf Failed,
    a database with the same name exists or specified file cannot be
    opened, or its location on UNC share</p>
  </blockquote>
  
  <p>it seems it is unable to read the SQL DataBase</p>