Link to home
Start Free TrialLog in
Avatar of HLRosenberger
HLRosenbergerFlag for United States of America

asked on

How do I retrieve application settings?

How do I retrieve application settings from the app.config file?  (See below) .  This is using VS 2010, .NET 4.0  


<applicationSettings>
        <PVE.Settings1>
            <setting name="ConnectionString" serializeAs="String">
                <value>Data Source=208.116.234.12; Database=tds; User Id=sa; Password=windy;</value>
            </setting>
            <setting name="InputView" serializeAs="String">
                <value>tds_provider_visitation_export</value>
            </setting>
            <setting name="OutputTable" serializeAs="String">
                <value>tds_provider_visitations</value>
            </setting>
        </PVE.Settings1>
    </applicationSettings>
Avatar of Hawkvalley1
Hawkvalley1
Flag of United States of America image

In your code:
My.Settings.ConnectionString
My.Settings.InputView
My.Settings.OutputTable

Open in new window

Avatar of Nasir Razzaq
Use the My.Settings.Settingname

so for InputView

My.Settings.InputView
Avatar of HLRosenberger

ASKER

My.Settings.xxxx does not work.  it does not recognize the setting name.

Did you add the settings on the Settings tab?
I added a new item, a setting file, and them I added my setting to that tab.  it created an app.config file with my settings.    

but I still cannot reference the setting in code.  I must be missing something.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Setting tab?  I thought I have to first add a Setting item.

Do there is a default setting tab?   let me look...  How do I get to it...
That's it!   I thought I first had to add a setting item.  If I add the setting to the project/setting tab, everything is fine!