locked
Select connection string based on user group RRS feed

  • Question

  • User383962173 posted

    Hi,

    We have 2 databases. Depends on the group after login, user need to be automatically switch to his (or her) connection string. I am not sure how to implement this, but am imaging that if I can have a parameter (like below example), then we will be able to point user to the right DB. Any thought or suggestion?

    connectionStrings>
       <add name="strConnect1" connectionString="Data Source=SQLSERVER\Instance;Initial Catalog=<GroupDB>;Persist Security Info=True;User  ID=xxx;Password=xxx" providerName="System.Data.SqlClient" />
    </connectionStrings>

    Thanks

    Wednesday, April 24, 2013 7:04 AM

Answers

All replies

  • User-629220960 posted

    HI,

     In your web.config file declare two connectionstrings for two database .

    When user is logging in  get the gruop by its type of what ever u want and then pass the group to datalayer there make sure of chosing the connectionstring by Group.

    Wednesday, April 24, 2013 7:15 AM
  • User-917364509 posted

    You could use a connection string builder:

    http://msdn.microsoft.com/en-us/library/ms254947.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 24, 2013 9:30 AM