-1

I have a requirement like, developed an ASP.net web application. I want to host this application for different companies with seperate database, but website shall be hosted only one copy in IIS. so, based on user login, the application should connect different database server.

For Ex: if user "xxx" login with credential and belogs to "ABC" company and the database is "ABC", then ABC data need to display on the web page.

if user "XYZ" login with credential and belogs to "HGJ" company and the database is "HGJ", then HGJ data need to display on the web page.

Can any one give good solution for the same.

Thanks in Advance

  • 2
    Store the database connection strings in Config or in the database and retrieve according to the user logging in, – Wheels73 Jun 28 '18 at 11:15
  • 2
    Have multiple connection strings on your web config And add code logic that binds each user name-login with a given connectionstring – apomene Jun 28 '18 at 11:15
  • 2
    Search for "multi tenant" on here - you'll find many similar questions. This one in particular might be useful: https://stackoverflow.com/questions/2213006/how-to-create-a-multi-tenant-database-with-shared-table-structures – Neville Kuyt Jun 28 '18 at 11:17
  • Thanks .. @Wheels73 – Ansari Tahir Jun 28 '18 at 11:18
  • Can we store Connectionstring in user table ...each user have connectionstring..?? – Ansari Tahir Jun 28 '18 at 11:19
  • like Username, Key, Connectionstring etc.....?? – Ansari Tahir Jun 28 '18 at 11:20
  • @AnsariTahir, sure, you can store connection strings and other configuration data in the database. However, be sure to do so securely (i.e. encrypt sensitive values). – Dan Guzman Jun 28 '18 at 11:22

1 Answers1

0

Maintain a separate database for the users and their database instances and after login load the entries from respective database. This approach will have performance problem as the SQL connections can't be cached and show slowness in the case of high users count.

SQL Server Connection Pooling

Multi-tenant SaaS database tenancy patterns

Ravi Sen
  • 101
  • 6