Reputation: 829
How do I write the path to a compact database so it will work for everyone working on the project?
My local path looks something like this:
SqlCeConnection con =
new SqlCeConnection(@"Data Source=C:\Users\Name\Documents\Visual Studio 2012\Projects\Unwanted\Local\Path\App_Data\Databas.sdf");
I think I've seen people use "~" sign to do stuff like this, anyhow I want to make this connection viable for everyone no matter how their mapping looks like.
Hope I made myself clear! :)
Upvotes: 1
Views: 4244
Reputation: 754230
The tilde (~
) is used in ASP.NET to denote the root of the web site - it cannot however be used in a SQL Server CE connection string.
You can try to just use
SqlCeConnection con =
new SqlCeConnection(@"Data Source=App_Data\Database.sdf");
Then the .NET app will look into the current directory (from where it's been started - often the (project dir)\bin\debug
folder) for a App_Data
folder and for a Database.sdf
file inside that folder.
Upvotes: 4