Asp.net connects to Access through the configuration file, asp. netaccess
This example describes how to connect asp.net to Access through the configuration file. Share it with you for your reference. The specific analysis is as follows:
Here, the Database blog. mdb is stored in App_Data.
Configuration File
<ConnectionStrings> // method 1 <add name = "access_conn" connectionString = "Provider = Microsoft. jet. oledb.4.0; data source = "/> <add name =" access_path "connectionString = "~ /App_Data/blog. mdb "/> // method 2 <add name =" blogConn "connectionString =" Provider = Microsoft. jet. OLEDB.4.0; Data Source = | DataDirectory | \ blog. mdb; Persist Security Info = True "/> </connectionStrings>
Calls in cs:
String sConn = ""; // call a sConn = ConfigurationManager. connectionStrings ["access_conn"]. connectionString + HttpContext. current. server. mapPath (ConfigurationManager. connectionStrings ["access_path"]. connectionString); // call two sConn = ConfigurationManager. connectionStrings ["blogConn"]. connectionString; OleDbConnection conn = new OleDbConnection (sConn); conn. open ();
I hope this article will help you design your asp.net program.