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

Posted on 2013-09-02
Medium Priority
Last Modified: 2013-09-07
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.
Question by:hougie40
  • 2

Accepted Solution

hougie40 earned 0 total points
ID: 39459189
Surprisingly somehow this worked.

  conn.ConnectionString = ConfigurationManager.AppSettings["RTICustomerConnectionString"];

So I didnt have to do anything extra difficult as previously thought.

Author Closing Comment

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

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
There is a wide range of advantages associated with the use of ASP.NET. This is why this programming framework is used to create excellent enterprise-class websites, technologies, and web applications.
Watch the video to know how one can repair corrupt Exchange OST file effortlessly and convert OST emails to MS Outlook PST file format by using Kernel for OST to PST converter tool. It can convert OST to MSG, MBOX, EML to access them. It can migrate…
If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …
Suggested Courses

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question