开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜