I have a problem...i'm developing my first WPF app in Visual Studio...It's a simple login app with a local .mdf database. The app works perfectly in debug mode and works well when i publish and run it in my laptop. But, when I run it in another pc, the database connection fails. I use the |DataDirectory|, but seems that not working. This is the steps that I do for develop my simple app:
1) I create two texbox and one button;
2)I assign the action at the button...in particulary i write this code
SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database\Database1.mdf;Integrated Security=True");
SqlDataAdapter sda = new SqlDataAdapter("Select * from Utenti Where Username='" + textBox.Text + "' and Password='" + textBox1.Text + " '", conn);
DataTable dt = new System.Data.DataTable();
3)Next I create in Solution explorer a folder called Database and into that folder I create a Database .mdf called Database1.mdf.
4)After that, I poupoulated it with fake data
5)I add the prerequisites "System" and "System.Configuration" at the project
6) I publish the app
What can i do? I spent a lot of effort, and i'm so confused...Thanks