title: How to deploy a windows forms database application
body: <p>I am developing a windows forms application that needs to communicate with the SQL Server. I'm facing a problem when I deploy the application once the connection string is trying to connect to an invalid address.</p>
  
  <p>I've already searched a lot and I found out the connection string must have the <code>|DataDirectory|</code> directive. Now the .mdf file is located on the directory <code>C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA</code>. Actually the connection string is:<code>connectionString="Server=.\SQLExpress;AttachDbFilename=|DataDirectory|PDVDatabase.mdf;Database=PDVDATABASE;Trusted_Connection=Yes;"</code></p>
  
  <p>The only way my app connects to the database is by the Server Explorer (I'm using Visual Studio 2013) where I get the static connection string of the .mdf file I set up in the app.config, but that way won't work after the deployment.</p>
  
  <p>My question is: How do I do to connect my app after the deployment in order to communicate with the .mdf file? (I'm using a setup project for deployment). What's can be wrong? </p>
  
  <p>Thanks.</p>