Using OleDb I am connecting to MS Access (v2003) database and my Project folder is MyHotApps and my OleDb Connection String is
MyConString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Users\Some User\Documents\Visual Studio 2010\WebSites\MyHotApps\Database\MyDbFile.mdb'";
As mentioned above my Project folder is MyHotApps and database file MyDbFile.mdb is located in Project_Folder<MyHotApps>\Database\MyDbFile.mdb
So, its too local for me that database file is inside the project folder and I need a Portable Connection String where ever I take the project folder I shouldn’t rewrite Connection String for that I tried the below manner which didn’t work
MyConString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source'=~Database\MyDbFile.mdb'";
Can anybody help me how to build a Portable Connection String I read some forms that says Database file should be placed inside App_Data file and I don’t know how to do that also. Anybody please tell me someway to build portable connection string.
You can make use of
HttpRequest.PhysicalApplicationPathAnd do something as below might resolve your protable path issue easily…