0

I'm having a problem with my local database file .mdf. After create my setup project, I read on internet that my .mdf files should be in the User's application data folder, that's why I'm having permissions error on my .mdf files. So, in the project setup, I right click and add a special folder "User´s Application Data Folder" and drag my .mdf files there.

If this will create a folder on the Windows app data of the client, with my database files, what should be my connection string?

Right now is this way:

connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\DatabaseIris.mdf;Integrated Security=True"
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Brugo
  • 101
  • 1
  • 9
  • It is not clear if you are using a config file to store your connectionstring or if you set this string by code. Could you explain it better? – Steve Aug 17 '17 at 22:03
  • Im using by code. On the App.config file on the visual studio. – Brugo Aug 17 '17 at 22:05

1 Answers1

0

See this answer:

https://stackoverflow.com/a/4243751/3043

Which suggests doing it like this:

connectionString="..;AttachDbFilename=|%AppData%|\DatabaseIris.mdf;.." />
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • This gives me a error. Invalid value for para 'attachdbfilename – Brugo Aug 17 '17 at 22:10
  • @Brugo did you read the _whole_ answer, specifically the part that replaces `%AppData%` with the special folder name - does the file actually exist in that folder? – D Stanley Aug 17 '17 at 22:11
  • Sry my friend. I dont know how to put this in my connection string. This line of code is all the visual studio give me about my connection string. Can you help me do this? – Brugo Aug 17 '17 at 22:15