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

  • Home
  • SEARCH
  • 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 6002803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:01:51+00:00 2026-05-23T01:01:51+00:00

I have ConnectionString defined in App.config file and I check the option not to

  • 0

I have ConnectionString defined in App.config file and I check the option not to include sensitive data so the password is left out from the connection string. In the application code I’m using Entity Framework and I’m accessing the db like this:

using (var db = new Entities())  
{                
     List<DATA> d = db.DATA.ToList();
}

I want authenticate user by the DB password – user enters it when the application launches.
The question is, how to add this password to the connection string when I don’t handle the ConnectionString manually in the code?

The farther I got is this:

ConnectionStringSettings conn = ConfigurationManager.ConnectionStrings["Entities"];
EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(conn.ConnectionString);
SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder(entityBuilder.ProviderConnectionString);
sqlBuilder.Password = "pwd";
entityBuilder.ProviderConnectionString = sqlBuilder.ToString();            
ConnectionStringSettings newConn = new ConnectionStringSettings("Entities",entityBuilder.ConnectionString);

But this still does not work and I cannot assing the new connection string to the ConfigurationManager.ConnectionStrings – it says it is read only value. How to overcome this?

  • 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-23T01:01:52+00:00Added an answer on May 23, 2026 at 1:01 am

    You can’t assign ConfigurationManager.ConnectionStrings because that just reflects your App.config, which your app can’t change.

    But you can tell the EF which connection string to use:

    using (var db = new Entities(entityBuilder.ToString()))  
    {                
         List<DATA> d = db.DATA.ToList();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a connection string defined in my web.config like: <connectionStrings> <add name=LibraryConnectionString connectionString=Server=.\SQLEXPRESS3;Database=Library;Integrated
If I have a connection string defined in my web.config file, how do I
In my applications web.config file I have a connection string stored. I encrypted it
I have done some searching around but have not been able to figure out
I have a Yii project with a main.php config file and dev.php config file
I have my NHibernate configuration successfully set up in my web.config file. However, I
I have a three tier set-up. Someone suggested I should get the ConnectionString from
I have the following connection string: Data Source=localhost\\SQLEXPRESS; , it complains that '' is
I decided to move Entity Connection String from app.config to code. However after setting
I have a view defined in SQL server 2008 that joins 4 tables together.

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.