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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:07:41+00:00 2026-06-10T13:07:41+00:00

When I add a database to a program, Visual Studio automatically creates the following

  • 0

When I add a database to a program, Visual Studio automatically creates the following connection string:

 <connectionStrings>
    <add name="TeamSortingTool.Properties.Settings.PlayerTeamConnectionString" connectionString="Data Source=|DataDirectory|\PlayerTeam.sdf" providerName="Microsoft.SqlServerCe.Client.3.5" />
    <add name="PlayerTeamEntities" connectionString="metadata=res://*/edmPlayerTeam.csdl|res://*/edmPlayerTeam.ssdl|res://*/edmPlayerTeam.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&quot;Data Source=|DataDirectory|\PlayerTeam.sdf&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

I am trying to allow the user to select the database that they would like to open. How do I modify the connection string programmatically without losing my associated dataset and tableadapter?

Thanks in advance 🙂

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

    you can use that method to call your connection string from your App.Config file to be used in the data connection or adapter

     public string GetConnectionStringByName()
            {
                string returnValue = null;
                ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["Connection Name Here"];
                if (settings != null)
                    returnValue = settings.ConnectionString;
                return returnValue;
            }
    

    when you add a new database to your project it takes the same connection Name of the existing database plus a number by default.
    so you can make the connection string as a variable and add the number to it when you add a new database.

    Edit

    By considering you will add databases to your project grammatically, then if you added a new data base.
    it will take that connection string’s Name:

    name="TeamSortingTool.Properties.Settings.PlayerTeamConnectionString1" 
    

    as it add a number at the end of the name of the existing database
    so, you can invest the method i provided, to add the specified connection string Something like that:

    public string GetConnectionStringByName(int DB_Number)
            {
                string returnValue = null;
                ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["Connection Name Here"];
                if (settings != null)
                    returnValue = settings.ConnectionString+Convert.ToString(DB_Number);
                return returnValue;
            }
    

    as the DB_Number variable could be saved in an XML file in order not to be loosed and its increased each time you add database.

    So, if you add a new database to the existing 1 the connection Name should be:

    name="TeamSortingTool.Properties.Settings.PlayerTeamConnectionString1" 
    

    and if you added another database the DB_Number will be increased by 1 to change the connection name to be :

    name="TeamSortingTool.Properties.Settings.PlayerTeamConnectionString2" 
    

    and enable the user to choose with connection string he wants to use.

    on the other hand . if your databases added manually before the application runs.
    it will be easier to Handle as what you just have to do is to save your connection string in a data structure as an array and call the wanted connection to use

    that is what i figured out from your question

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

Sidebar

Related Questions

I have written a C# program in Visual Studio 2010 . I use database
this program is for class to display the database in Listview.i want to add
I have finished a program using sql server and visual studio using c# language
I am working on a Visual C# program and have added a local database
I'm trying to re-install SQL Server Express from http://www.microsoft.com/express/Database/ . Visual Studio Web was
I have created a database program where I am able to add the data
I want to add database elements into array. how do I do that. the
How can I add a database field to the Magento global search? I want
How to add a existing database file say (ex:- x.sdf) and dump the data
I'm unable to add an mdf database file by right clicking on the project

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.