2

I want to deploy my WPF project but at the client machine it throws an exception that connection is not able to open.

I use a hardcoded string I don't know how to set dynamic connection string which changes at every computer. Someone please guide me with deployment of a WPF project with local SQL Server database or how to set connection string dynamically.

What I have done:

  1. Deploy and export database with .EXE
  2. Deploy without database and with SQL script so on the client machine it creates database before starting setup

This is the connection string which I am using:

<add name="connect"
     connectionString="Data Source=(LocalDB)\FoodManagmentUpdate;AttachDbFilename=C:\Program Files (x86)\SolBuz\Shreeji Snacks\FoodManagmentUpdate.mdf;Integrated Security=True"
     providerName="System.Data.SqlClient" />

I already tried with :

<add name="connect"
     connectionString="Data Source=(LocalDB)\FoodManagmentUpdate;AttachDbFilename=|Data Dictionary|FoodManagmentUpdate.mdf;Integrated Security=True"
     providerName="System.Data.SqlClient" />

I installed SqlLocalDb on my client's machine, but still it won't work. And FoodManagmentUpdate is the object of SqlLocalDb which I also created on the client computer.

1
  • 1
    Can you share some Exception details? Commented Aug 27, 2016 at 18:12

1 Answer 1

3

I Changed my AttachDbFileName=|DataDirectory|\Databasename.mdf and now it works but i have to copy whole folder 'bin' which resides in your solution folder and that bin folder must contain your database in it. This way i get my solution.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.