Hi,
I am using MS Access as database for web site. To create connection string I used following code.
string dppath="";
OleDbConnection MSAConn;
dbPath = HttpContext.Current.Server.MapPath("~");
dbPath = dbPath + "\\App_Data\\dbname.accdb";
MSAConn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + dbPath + ";");
Also I have tried ...
MSAConn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" +
HttpContext.Current.Server.MapPath("\App_Data\dbname.accdb") + ";");
These both connection string doesn't work . I am hosting this application on Shared Hosting Server.
Any help appreciated.
Regards,
Vikram
Loading

Hemant KumarRank #1,202 · 1.5K reputationPosted Oct 13, 2011, 12:09 AM EDT
The Connection String for MS Access can be set as ;
public bool OpenConnection() { OleDbConnection con; con = new OleDbConnection(constr); if (con.State != ConnectionState.Open) { try { con.Open(); return true; } catch (Exception) { return false; } } else return false; }VikramRank #9,295 · 208 reputationPosted Oct 13, 2011, 12:30 AM EDT
There is no any password I have set for MS Access Database. Whenever I give local path of machine then it is working fine. Now I want to upload this web site on shared hosting server whose path I don't know. So I tried with Server.MapPath() function in above format which didn't work for me.
Hope I have clarify my issue.
Regards,
Vikram Patil
Sam HobbsRank #107 · 20.5K reputationPosted Oct 13, 2011, 12:45 PM EDT
You must use the documentation provided by your shared hosting service. They should tell you what you need for the connection string.