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 7912935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:43:33+00:00 2026-06-03T13:43:33+00:00

I am fairly new to c#. So far so good with learning. I do

  • 0

I am fairly new to c#. So far so good with learning. I do have one question, well maybe two.

How do you create a user dialog to allow the selection of a connection string when the project starts? I have 4 databases with the same schema and would like to allow the user to choose which to connect to when they launch the program.

I am currently using datasets but am willing to learn/try another method to acheive the desired result.

  • 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-06-03T13:43:34+00:00Added an answer on June 3, 2026 at 1:43 pm

    Put them into the config’s connectionStrings area and provide the user with a ComboBox containing the names of the connection strings. Then use the one selected.

    In your config:

    <connectionStrings>
      <add name="Environment1" connectionString="connString1" providerName="System.Data.SqlClient" />
      <add name="Environment2" connectionString="connString2" providerName="System.Data.SqlClient" />
      <add name="Environment3" connectionString="connString3" providerName="System.Data.SqlClient" />
      <add name="Environment4" connectionString="connString4" providerName="System.Data.SqlClient" />
    </connectionStrings>
    

    In your code, add the connection strings to a ComboBox:

    foreach (ConnectionStringSettings connString in ConfigurationManager.ConnectionStrings)
    {
        myComboBox.Items.Add(connString.Name);
    }
    

    Get the name from the ComboBox, then get the connString you need and use it:

    // Access chosen one:
    string chosenName = (string)myComboBox.SelectedItem;
    string connString = ConfigurationManager.ConnectionStrings[chosenName].ConnectionString;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very much new to programming and have been doing fairly well so far.
I'm fairly new to JS, here's what I have so far. I can get
I'm fairly new to jquery and so far i have got my code to
I'm fairly new to Hibernate and PostgreSQL, but so far it's going well, although
I am new to fairly new to AS3 and I have found myself needing
I'm fairly new to Subversion. Most of my work so far has been with
I'm fairly new to WCF but I have a WCF Service hosted in IIS
fairly new to Android development. I made a function for the user to call
I am fairly new to Android programming, but I am getting pretty good at
I'm fairly new to facebook development, but have experience with PHP and JavaScript. I've

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.