The
configures the Access database driver and database file names in Web. config.
See code
<appSettings>
<add key= "Dbdriver" value= "provider=microsoft.jet.oledb.4.0; Data Source = "/>
<add key=" DBName "value=" Company.mdb "/>
</appSettings>
At the database access layer, as Gets the Access database link string in OleDBHelper.cs.
/**////<summary>
//Get the database join string from Web. config
//</summary>
//Get the database name from the configuration file
Public Static readonly String DBName = ConfigurationManager.AppSettings.Get ("DBName"). ToString ();
//Get database driven from configuration file
public static readonly string dbdriver = ConfigurationManager.AppSettings.Get ("Dbdriver"). ToString ();
//Get database connection string
Private static string dbconnectionstring = Dbdriver + HttpContext.Current.Server.MapPath ( HttpContext.Current.Request.ApplicationPath + "/app_data/") + DBName;
//Establish database connection object
private static OleDbConnection oledbconn = new OleDbConnection (dbconnectionstring); After the
is set up, you can access the database correctly through the above code, regardless of any subdirectories.