I made a perfect application and I have to make insallation for that app. But i have a localDB and there is my problem, how, and where to store mdf file. I had searched about it on google but I haven't arrived at a solution yet.
I have tried two solutions.
- Include mdf file to installation folder via exe file. When I do that , program starts and executes fine, database works untill i have update or insert commands, exception is thrown which says that db is read-only. I tried running with administrator or changing privilegies, but still same problem.
- Save mdf file to mydocuments or appdata That way I create special folder via VS installer and add mdf file there, but problem is I don't know how to make relative connection string, because it is set to datadirectory.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="Test1" connectionString=" Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Artikli.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Where other programs store their databases? What is the best way to do it?