1

I'm building an application for our client base, all of whom have pre-existing database's. The business owners will be able to read and report on their local business DB's through this app, all data will be specific to their business.

I'm planning on doing the following:

  • Create "master" account database to store info about all our clients accounts
  • Upload existing databases to our server solution
  • On login, check against account db and load appropriate db to persist through client sessions

My question is, is it best to put every data connection in as a new entry in web.config and just reference the connstrings throughout the app off a session variable ie:

  • Client A Login -> Uses Database A -> Store DB_A_Connstring as session var
  • Client B Login -> Uses Database B -> Store DB_B_Connstring as session var

Or is there a better approach? Thanks for the input.

EDIT: I'll note that each db will have a GUID and I'll be constantly validating the connection against account credentials so I'm not too concerned about the security of this approach, just it's implementation as a viable option.

1 Answer 1

1

How often will you be adding/removing databases? If rarely, web.config should be ok. If often, I would only store the conn string to the master database in the web.config, and store the details of each client database in a table there.

Though after reading your question again, "hundreds", to me, means storing them in a table rather than Web.config, even if they are never updated. I simply wouldn't want that many hard coded strings in a config file.

Sign up to request clarification or add additional context in comments.

8 Comments

Yea, ideally we'd like to automate the entire setup process...and we'll be adding new db's on a daily/weekly basis so storing db info in the account db is probably the smarter approach
One quick question...if I were to store all client db info in the account db, wouldn't I need to store all db connection info in a session variable for that user, potentially exposing credentials and all of their data while they are connected?
No reason to store it in session variables. The default thread pool will cache all connections for you, and matches them based on the conn string. So just create/dispose of connections normally (using the string loaded from the master DB) that way users from the same company will benefit from recycled connections to the same DB.
So changing the connstring programmatically, it should persist throughout the session? That sounds like a win-win...I'm going to test it out then come back and give you a big green check in a few. Thanks for the suggestions
Yep only the strings, connections will be on a per-query basis
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.