I have a Windows Forms app with an integrated LocalDB SQL database through Visual Studio with a RecipeDB.mdf file that resides in the folder with the rest of the application. I am also using LINQ to SQL. I have everything working fine, and I am ready to publish the app and turn in the project for school.
The one problem I have is that for some reason if I use AttachDbFilename=|DataDirectory|\RecipeDatabase.mdf in my connection string in my App.Config, it doesn’t save to the database. It requires that I use the full path of C:\Users\Tania\source\repos\Old\HealthierRecipes\HealthierRecipes\RecipeDB.mdf.
That has been fine while I was creating the project, but it won’t work for publishing it. I need the program to be able to be installed wherever people want it, and for it to be able to find its database.
So how do I get it to save to the correct place? Is there a way to make a variable for the App.config connection string and have people put their path in a text file? Or is there some way to get the database to acknowledge the |DataDirectory| path?
Any help would be appreciated.