无法取得ConnectionSettings的问题

app.config为

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
   <add
       name="mainDB"
       connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=F:\Develop\COMMON\db.mdb"
       providerName="NBear.Data.MsAccess.AccessDbProvider"
   />
  </connectionStrings>
</configuration>

 

用System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]无法取得,原因是ConfigurationSettings过时了。

用System.Configuration.ConfigurationManager.ConnectionStrings["mainDB"].ConnectionString就ok了

 

你可能感兴趣的:(Connection)