Access application settings from code
Hi , I stored my connection in application settings i.e. project > properties> settings tab. Now i need to access the connection string from code. How do i do it ?? any help is appreciated, red
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

tsosane shabe2 reputationPosted Feb 3, 2007, 12:37 PM EST
Can you please help me with simple c# code to create poll and be able to show number of people voted , Results in pecentages and results in bar graphs
red man14 reputationPosted Feb 3, 2007, 4:56 PM EST
Ken Linder9 reputationPosted Feb 9, 2007, 6:09 AM EST
Just access the settings like this...
Properties.Settings.Default.SettingName
Substitute your setting name for SettingName. That will return a string.
Now, a cool thing you can do with settings is save them! Just create a setting in the same place you set up your connection string. Say for example, you create a setting called UserEmail. Here's how you would save to it.
Properties.Settings.Default.UserEmail = "[email protected]"; // sample e-mail
Properties.Settings.Default.Save();
Now, to retrieve it & display on a label, do this...
label1.Text = Properties.Settings.Default.UserEmail;
It WILL persist these settings from one run time to another. This is MUCH easier than using regristy settings, IMHO!!!