I have replaced the bottom line with the code that is in comments to make the location dynamic but it doesn't work. I have also changed the app.config file accordingly but still no hope. Could someone please guide me.
// public string str = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\b5012622\Desktop\Jan_Prototype\DB.mdf;Integrated Security=True";
public string str = ConfigurationManager.ConnectionStrings["connectionstrings"].ConnectionString;
Here is the app.config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionstrings>
<add name="dbConnection">
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\DB.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient"
</add>
</connectionstrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>