Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3320224
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:55:04+00:00 2026-05-17T22:55:04+00:00

I have a Winform app that has 16 SQL Connections currently stored in the

  • 0

I have a Winform app that has 16 SQL Connections currently stored in the DAL Projects Settings.settings.

I am trying to write a “Manager” class to simplify this(like here). However, most of the examples I find on the web seem to use ConfigurationSettings.AppSettings["something"]. While, I WAS using Properties.Settings.Default.something.

Can someone, please, explain which is considered CORRECT and why for a Desktop applications?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:55:05+00:00Added an answer on May 17, 2026 at 10:55 pm

    I’ve never been a big fan of putting sql connection strings into configuration files for software. Users have a habit of goofing them up out of curiosity or stupidity (or some combination of the two). I like to put all of my connection strings (development, model, production, whatever) into the Properties of my data access library, and include within it a ConfigurationSettings class that I use to access them based on some property that is set by the consuming application:

    public class ConfigurationSettings
    {
    
        public static string MyConnectionString
        {
        get
                if(ConfigurationSettings.TestMode)
                    return Properties.Settings.Default.MyConnectionStringTest;
                else
                    return Properties.Settings.Default.MyConnectionStringProd;
        }
        }
    
        // I typically only have test and not-test. This could
        // easily be some other combination of values to satisfy
        // multiple environments.
        public static bool TestMode { get; private set;}
    }
    

    This allows me to call the static properties of this class through a common name and have all connection strings available depending on some criteria. This gets your specific datasets, entities, whatever data model you’re using from being in the business of worrying about connection strings and the settings can be compiled into the .dll (and no longer need to worry about them). This method can also be modified to pull settings from an app.config (which I do for ASP.Net sites) in a similar method.

    UPDATE: There really is no “correct” way as you imply. The app.config was designed to hold configuration settings that are modifiable without rebuilding the application. Property Settings were designed to hold settings that are not modifiable. So both are perfectly valid. Probably the most “correct” way is a way that makes sense both for your application and for your development team.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a winform app that uses LinqToSql as it's DAL. There is a
I have a winform app that calls a web service to check for updates.
I have a web page that is being displaying in a winform app using
So we have a winforms app that in the task manager should anywhere from
I have a medium sized WinForm App ( 1 Form that hosts 40 user
I have a C# 4.0 Winform app that I just upgraded from 3.5 to
I have a DataGridView in a WinForms 2.0 App that has a lot of
I'm trying to have a grid that has items that have a custom layout/feel.
I have a DataGridView control in a winforms app that I'm working on. The
I have an app that I've written in C#/WinForms ( my little app ).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.