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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:28:33+00:00 2026-05-17T15:28:33+00:00

I have a database called Config where I have a table called Customer In

  • 0

I have a database called
“Config” where I have a table called “Customer”
In the Customer table I hold the login credentials, along with a connection String to the client’s database.

Inside of my controller I’m checking to see what customer database i’m querying

        String connectionString = "";
        if (id == 1)
            connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Client1.mdf;Integrated Security=True;User Instance=True";
        else if (id == 2)
            connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Client2.mdf;Integrated Security=True;User Instance=True";

        using (TestDbaseDataContext db = new TestDbaseDataContext(connectionString))
        {
            var searchRecords = db.SearchRecords;
            return View(searchRecords.ToList());
        }

There will be an undetermined number of client’s using separate databases, these connection strings will change based on archived status, and other factors. I don’t think hard coding these strings in app.config will do what I need.

I have a “Master” database, that holds all of the client’s configuration settings, along with the client’s database connection string. The mater database is only used to mitigate which client database to search. I store the connection strings in the master database so I can pass that connection string for the logged in customer to query the correct database. It is a requirement to have each client in it’s own database

How would you store this connection string so I can pass to my datacontext when needed?
Should it be stored in a session variable, or should I query the Config database Customer table in each controller method?

  • 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-17T15:28:33+00:00Added an answer on May 17, 2026 at 3:28 pm

    I’ve set up a similar “siloed” multi-client application before. This is a good case for a session variable. Each user relates to a client, which has its own database. On login, each user should get a “context” object in Session state containing all necessary identifying data, including database connection string.

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

Sidebar

Related Questions

I have a database table called Posts which stores all the information regarding an
I have a simple database table called Entries: class CreateEntries < ActiveRecord::Migration def self.up
Lets say I have a table in a sql server 2000 database called TransactionType:
I have a database table called A and now i have create a new
I have a database called foo and a database called bar. I have a
I have a database field called abCode , that I want to map to
I have two tables in my database, called ratings and movies . Ratings: |
I have a couple of tables in my database, one called Task , and
I have database with many tables. In the first table, I have a field
I have a database table and one of the fields (not the primary key)

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.