0

I was toying around with a rogue application and realized that if I deploy my program on another computer, it would crash because my connection string is an absolute path.

Data Source=(LocalDB)\v11.0;AttachDbFilename="C:\Users\AD\Documents\Visual Studio 2013\Projects\botSuite test\botSuite test\Users.mdf";Integrated Security=True;Connect Timeout=30

I thought about looking in the directory, setting a string to its filepath and using that to deal with the issue but it seems like there should be an easier way.

Argent Drake
  • 71
  • 11
  • 9
    Store the connection string in the `app.config` file. – Ron Beyer Jul 08 '15 at 02:22
  • 1
    Also check out the `|DataDirectory|` string substitution: http://stackoverflow.com/questions/1409358/ado-net-datadirectory-where-is-this-documented – Matthew Jul 08 '15 at 03:15
  • This has solved my issue, I recall learning this out of my book but I guess it faded away over time. Thank you again! To anyone else finding this thread and wondering how to pull values out of app.config check out http://stackoverflow.com/questions/2400097/reading-from-app-config-file – Argent Drake Jul 08 '15 at 23:43

0 Answers0