How can I access application settings?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGhpbCBKb2huc29u?=

    How can I access application settings?

    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.

    --
    Regards,

    Phillip Johnson (MCSD For .NET)
    PJ Software Development

  • =?Utf-8?B?TW9ydGVuIFdlbm5ldmlrIFtDIyBNVlBd?=

    #2
    RE: How can I access application settings?

    Hi Phil,

    If you added an appSetting called DBConnection

    string value = ConfigurationMa nager.AppSettin gs["DBConnecti on"];

    If you added a connectionStrin g called DBConnection

    string value =
    ConfigurationMa nager.Connectio nStrings["DBConnecti on"].ConnectionStri ng;

    If you added a Setting called DBConnection

    string value = Properties.Sett ings.Default.DB Connection;

    or

    string value =
    ConfigurationMa nager.Connectio nStrings["MyNameSpace.Pr operties.Settin gs.DBConnection "].ConnectionStri ng


    --
    Happy Coding!
    Morten Wennevik [C# MVP]


    "Phil Johnson" wrote:
    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.
    >
    --
    Regards,
    >
    Phillip Johnson (MCSD For .NET)
    PJ Software Development
    www.pjsoftwaredevelopment.com

    Comment

    • =?Utf-8?B?UGhpbCBKb2huc29u?=

      #3
      RE: How can I access application settings?

      Thanks Morten,

      I'm sure one of those will work!

      --
      Regards,

      Phillip Johnson (MCSD For .NET)
      PJ Software Development



      "Morten Wennevik [C# MVP]" wrote:
      Hi Phil,
      >
      If you added an appSetting called DBConnection
      >
      string value = ConfigurationMa nager.AppSettin gs["DBConnecti on"];
      >
      If you added a connectionStrin g called DBConnection
      >
      string value =
      ConfigurationMa nager.Connectio nStrings["DBConnecti on"].ConnectionStri ng;
      >
      If you added a Setting called DBConnection
      >
      string value = Properties.Sett ings.Default.DB Connection;
      >
      or
      >
      string value =
      ConfigurationMa nager.Connectio nStrings["MyNameSpace.Pr operties.Settin gs.DBConnection "].ConnectionStri ng
      >
      >
      --
      Happy Coding!
      Morten Wennevik [C# MVP]
      >
      >
      "Phil Johnson" wrote:
      >
      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.

      --
      Regards,

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

      Comment

      Working...