Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Appsettings from app.config (C#)

Posted on 2005-03-27
4
Medium Priority
?
3,693 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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Starting up a Project

572 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