0

so I have a question on asp.net sql stringconnection. So basically what I have now, is

Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\mateusz\Desktop\RideShare\RideShare\App_Data\RideShare.mdf;Integrated Security=True

While this works on my local machine, if I want to open it somewhere else, I have to change the path up until the \Rideshare folder. Is there a way to provide the string from say

\App_Data\RideShare.mdf;Integrated Security=True

? When linking to different pages you can do something like ~/page.aspx, is it possible to do it with the connectionstring?

Mateusz
  • 29
  • 7
  • 1
    You want to use a relative path... take a look at this: http://stackoverflow.com/questions/1833640/connection-string-with-relative-path-to-the-database-file – Steven Mays Nov 23 '16 at 15:28

1 Answers1

0

I am currently working on something similar. The way I achieve this is by setting a relative path like this:

Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\RideShare.mdf;Integrated Security=True
Luis Pascual
  • 256
  • 1
  • 3
  • 13