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:
- Deploy and export database with .EXE
- 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.