Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

How can I access application settings?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phil Johnson - 09 Mar 2008 19:54 GMT
Hi, I have right clicked my project in VS2008 and added a DB Connection
application setting.

How do I access these settings from my code?

I know this must be pretty simple, but I cannot see how to do it.

Signature

Regards,

Phillip Johnson (MCSD For .NET)
PJ Software Development
www.pjsoftwaredevelopment.com

Morten Wennevik [C# MVP] - 10 Mar 2008 07:22 GMT
Hi Phil,

If you added an appSetting called DBConnection

string value = ConfigurationManager.AppSettings["DBConnection"];

If you added a connectionString called DBConnection

string value =
ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;

If you added a Setting called DBConnection

string value = Properties.Settings.Default.DBConnection;

or

string value =
ConfigurationManager.ConnectionStrings["MyNameSpace.Properties.Settings.DBConnection"].ConnectionString

Signature

Happy Coding!
Morten Wennevik [C# MVP]

> Hi, I have right clicked my project in VS2008 and added a DB Connection
> application setting.
>
> How do I access these settings from my code?
>
> I know this must be pretty simple, but I cannot see how to do it.
Phil Johnson - 10 Mar 2008 09:49 GMT
Thanks Morten,

I'm sure one of those will work!

Signature

Regards,

Phillip Johnson (MCSD For .NET)
PJ Software Development
www.pjsoftwaredevelopment.com

> Hi Phil,
>
[quoted text clipped - 22 lines]
> >
> > I know this must be pretty simple, but I cannot see how to do it.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.