Link to home
Start Free TrialLog in
Avatar of Steve Hougom
Steve HougomFlag for United States of America

asked on

Help with accessing a section of web.config for db conn

I have a section of my web.config im trying to use as a database connection string.

Im just trying to do this in the following way but am having trouble accessing the value in the web config where the connection string is.

SqlConnection conn = new SqlConnection();
conn.connectionstring = ?

Open in new window

Here is the section in the web.config im trying to access.

 <section name="csrportal" type="System.Configuration.DictionarySectionHandler, System"/>
<csportal>
 <add key="RTICustomerConnectionString" value="server=(local);Integrated Security=SSPI;database=dbname;Application Name=appname"/>

Open in new window


Im not sure if I use ConfigurationManager.GetSection or what i need to use to get to the connection string.

The csportal section is in a custom section it does not exist in <appSettings> or <connectionStrings> sections.
Avatar of Andrew Doades
Andrew Doades
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER CERTIFIED SOLUTION
Avatar of Steve Hougom
Steve Hougom
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve Hougom

ASKER

It turned out the solution was something a little different than I expected.