开发者

What is the best way to dynamically load connection strings

开发者 https://www.devze.com 2022-12-14 10:42 出处:网络
I\'ve seen some other posts in this topic, but thought I would ask the question with a description on my problem.

I've seen some other posts in this topic, but thought I would ask the question with a description on my problem.

I have a login page which uses SQL provider for the user login. Then the user should be redirected to the main application. This is a web based CRM application in which we have multiple clients.

My goal is to use a single web site, but multiple SQL databases. And the user that signs in should 开发者_如何学JAVAuse a connection string that corresponds to the company he belongs.

Any good ideas?


Would it work to create a simple map between the user's organization and the appropriate database connection?

It could be as simple as a Dictionary<string, string> initialized in global.asax. The key would be the company and the name of a connection string defined in web.config.

If you need to make this configurable, you can load the values for such a dictionary from a custom configuration section.


Use ConnectionStrings in Web.Config. Check this link for more information : How to: Read Connection Strings from the Web.config File. You can create a Key as the Name of the organization and value as the connection string that corresponds to the organization.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号