<connectionStrings>
<add name = "mdbconn" [String, Required, Collection Key] connectionString = "" [String, Required] providerName = "System.Data.SqlClient" [String] />
</connectionStrings>
读取:
string strConnection = ConfigurationManager.ConnectionStrings["mdbconn"].ToString();
第二种方法设置:
<appSettings>
<add key="strcon" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Backup\我的文档\Visual Studio 2005\WebSites\4ec\App_Data\company.mdb"/>
</appSettings>
<connectionStrings/>
读取:
OleDbConnection con = new OleDbConnection(ConfigurationSettings.AppSettings["strcon"]);
<add name = "mdbconn" [String, Required, Collection Key] connectionString = "" [String, Required] providerName = "System.Data.SqlClient" [String] />
</connectionStrings>
读取:
string strConnection = ConfigurationManager.ConnectionStrings["mdbconn"].ToString();
第二种方法设置:
<appSettings>
<add key="strcon" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Backup\我的文档\Visual Studio 2005\WebSites\4ec\App_Data\company.mdb"/>
</appSettings>
<connectionStrings/>
读取:
OleDbConnection con = new OleDbConnection(ConfigurationSettings.AppSettings["strcon"]);