Use server. mappath like ASP in Web. config to retrieve the database path
However, Web. config does not know server. mappath. This method causesProgramDebugging fails.
You can port the program path without modifying the ACCESS database path.
The Web. config statement is as follows:
<Deleetask>
<Add key = "connstr" value = "provider = Microsoft. Jet. oledb.4.0; Data Source ="/>
<Add key = "dbpath" value = "/appdata/mydata. mdb"/>
</Appsettings>
In the program's data category class, I take "connstr" and "dbpath" and connect them to a string.
CodeAs follows:
/// <Summary>
/// (Static) returns the database connection string.
/// </Summary>
Protected static string getconnstring ()
{
Return
System. configuration. configurationsettings. appsettings ["connstr"] + system. web. httpcontext. current. server. mappath (system. configuration. configurationsettings. appsettings ["datapath"]) + ";";
}