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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:40:42+00:00 2026-05-13T07:40:42+00:00

I have asked this question What is the best way to dynamically load connection

  • 0

I have asked this question What is the best way to dynamically load connection strings

But maybe it’s better to ask the question a little different.

I have a CRM solution where I have different SQL databases for each company, but I would like to try to only have one IIS site, since the site is always equal except for the SqlConnectionString in the Web.config file. I use LinqToSql and generates the classes automatic using the tools in VS2008. This means that I have the DataClasses which is automatic generated. I found that this class reads the connection string from the web.config in this line:

public DataClassesDataContext() : 
    base(global::System.Configuration.ConfigurationManager
             .ConnectionStrings["TheConnectionString"].ConnectionString,
             mappingSource)
{
    OnCreated();
}

The users all logs into the same IIS site which I want to authenticate against AD and then redirect them to the CRM site, when I do I would like to dynamic get the right ConnectionString and make the Linq class use that.

Am I on the right track to make this happen? And if so, how do I achieve to load the connectionstring dynamic for the linq classes, the file which the code above is found is autogenerated and is deleted every time I compile.

Any ideas?

  • 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-13T07:40:42+00:00Added an answer on May 13, 2026 at 7:40 am

    You can do that if in linqmetal desinger click on it and then in the property window on sql connection you set to blank so the autogenerate dont owerwrite you code.
    Then you create partial class for you datacontex and then you create this contructor by your self example:

     public partial class DataClassesDataContext
        {
            public DataClassesDataContext()
                : base(StaticMethodThatYouDoLogicForConnStringDecision(), mappingSource)
            {
    
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asked this question before but did not get the satisfied answer as
i asked this question yesterday but it doesnt seem to have asked properly so
I have just asked this question an hour ago but with regards to IE8
I am sorry I have already asked this question on Superuser, but nobody answers
I asked this question before but with less information than I have now. What
This question may have been asked before, but I'm starting to get into game
Okay, I know this question have been asked plenty of times already, but I
I know many have asked this question, but I think my situation is a
In this question I asked how (programatically) was the best way to transfer data
This question may have been asked before, but I couldn't find an answer to

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.