Reputation: 473
I created a database with VS2015 express when I use this connecion string :
Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename="C:\Users\example\documents\visual studio 2015\Projects\materials summury\Rexnord materials summury\Database1.mdf";Integrated Security=True
The connection is working, but when I use this one :
Data Source=(LocalDB)\MSSQLLocalDB; AttachDbFilename=".\ Database1.mdf";Integrated Security=true;
I got the message : the login failed. can you help me with this relative connection ? Thanks in advance
Upvotes: 0
Views: 309
Reputation: 8584
ConnectionString
allows for metadata like DataDirectory
You can use Data Source=[DataDirectory]Database1.mdf
to get the the project root. Using DataDirectory
or it's equivelant symbol ~
you cannot go higher up then the the solutions folder itself.
https://msdn.microsoft.com/en-us/library/cc716756.aspx
Upvotes: 1