?
Solved

Appsettings from app.config (C#)

Posted on 2005-03-27
4
Medium Priority
?
3,657 Views
Last Modified: 2008-01-09
I created a database layer component using C#. I have a app.config file where I have mentioned the SQLconnectionstring. Database layer component need to get the connection string information from the config file, it is not doing so, I am not able to figure out - pls help.
0
Comment
Question by:rgshankar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
dttri earned 225 total points
ID: 13641361
 Hi,
  Have a look there:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vboriintroductiontoapplicationsettingstorage.asp

  You can use:
this.sqlConnection1.ConnectionString = ((string)( System.Configuration.ConfigurationSettings.AppSettings.GetValues("SqlConnection1.ConnectionString"))));
as in the example there.
0
 
LVL 4

Assisted Solution

by:Jarodtweiss
Jarodtweiss earned 150 total points
ID: 13643384
or more simply add

using System.Configuration;

and then

this.sqlConnection1.ConnectionString = ConfigurationSettings.AppSettings["SqlConnection1.ConnectionString"];
That indexer is already returning a string, no conversion is needed!
0
 

Author Comment

by:rgshankar
ID: 13710412
Thanks..
0
 
LVL 7

Expert Comment

by:dttri
ID: 13718444
 I don't know why you rate B? :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Six Sigma Control Plans
Suggested Courses

777 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