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.
ASP.NETC#

Avatar of undefined
Last Comment
Steve Hougom
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Steve Hougom
Steve Hougom
Flag of United States of America image

ASKER

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

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo