开发者

Getting connection string from App.config and using it in a Linq dataContext

开发者 https://www.devze.com 2023-02-04 07:02 出处:网络
How should I extract the following connection string and apply it to my Linq context?I know the Linq portion, but am weak with the System.Configuration section.

How should I extract the following connection string and apply it to my Linq context? I know the Linq portion, but am weak with the System.Configuration section.

  <connectionStrings>
        <!-- Production

        <add name="Management_Report_Emailer.Properties.Settings.DWConnectionString"
            connectionString="Data Source=prodSQL01;Initial Catalog=DW;Integrated Security=True"
            providerName="System.Data.SqlClient" />-->


      <!-- QA-->

      <add name="Management_Report_Emailer.Properties.Settings.DWConnectionString"
       开发者_开发百科     connectionString="Data Source=qaSQL01;Initial Catalog=DW;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>


ConfigurationManager.ConnectionStrings("Management_Report_Emailer.Properties.Settings.DWConnectionString").ConnectionString


ConfigurationManager.ConnectionStrings["Management_Report_Emailer.Properties.Settings.DWConnectionString"].ConnectionString;
0

精彩评论

暂无评论...
验证码 换一张
取 消