sql连接:
webconfig中:
<configuration>
<appSettings>
<add key="logPath" value="c:\log.txt"/>
<add key="ConnectionString" value="server=.;database=test;uid=sa;password=sa"/>
</appSettings>
</configuration>
调用时:
string conStr= System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToString();
access连接:
webconfig中
<configuration>
<appSettings>
<add key="oledb" value="Provider=Microsoft.Jet.OLEDB.4.0;Data source="/>
<add key="oledp" value="~/App_Data/db.mdb;" />
</appSettings>
</configuration>
调用时:
OleDbConnection oldCon = new OleDbConnection(ConfigurationSettings.AppSettings["oledb"] + System.Web.HttpContext.Current.Server.MapPath(ConfigurationSettings.AppSettings["oledp"].Trim()));