Trouble using App.Config ConnectionString (String works don't understand code)
I'm using VS2010 on XP.
Below is the app.config file i'm trying to use. I don't understand the part about the connection string. I have two calls to the database that uses this same connection string, but i don't know how to use it.
But how do i access the connection string? I don't understand that block of code AT ALL! I understand that the connection string is composed of different parts. But i've always seen it as basically one long string separated by semicolons.
Thanks for your help!
Last edited by maurices5000; July 19th, 2012 at 11:02 AM.
Re: Trouble using App.Config ConnectionString (String works don't understand code)
Since both AppSettings and ConnectionsStrings are both collections derived from ConfigurationElementCollect they'll both work the same. They expose a Item[str] (actually a this[key]) property that allows you to access the item by it's key. To find this in msdn, you need to look at the ConfigurationElementCollection base class and the Item property. It's a bit hard to find, but many collections work this way, so if you see it in the future, you'll know you can access an item using this approach.