ASP.NET连接ACCESS数据库web.config内路径最优写法

    技术2022-05-11  31

    ASP.NET连接ACCESS数据库web.config内路径最优写法

    <appSettings> <add key="SQLConnString" value="provider=microsoft.jet.oledb.4.0;data source="/> <add key="dbPath" value="~/App_Data/mydata.mdb"/> </appSettings> 程序中的数据访问类中我把"SQLConnString"和"dbPath"取出来连接成一个字符串"CONN_STRING_NON_DTC" public static readonly string CONN_STRING_NON_DTC = System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString() + System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["dbPath"]) + ";";

     

     

     


    最新回复(0)