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"/>
 <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 undefined
Last Comment
Steve Hougom

8/22/2022 - Mon
Andrew Doades

Steve Hougom

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Steve Hougom

It turned out the solution was something a little different than I expected.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck