Reputation: 4432
I'm using some Microsoft sample code and they have an example of using ConfigurationManager.ConnectionStrings to pull a series of connection strings from the app.config and allow an individual to choose the string they want. I don't need the ability to choose, I just want to get the specific named connection string I have defined. Something like (yes, I know this isn't real code):
Configuration.ConnectionStrings.Select("myconnection")
Is this possible? If not, how should I pull in a single connection string?
Upvotes: 0
Views: 254
Reputation: 59446
ConfigurationManager.ConnectionStrings["my_connection"].ConnectionString
Upvotes: 1
Reputation: 8072
You need to reference System.Configuration.ConfigurationManager
ConfigurationManager.ConnectionStrings["myconnection"].ConnectionString
Upvotes: 2