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;
精彩评论