Web application running multiple instances

Posts   
 
    
gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 31-Oct-2005 10:51:18   

Hi Folks,

I've been thinkig about making my web application useable by multiple companies by giving them different databases. This means, upon their logon I find out which client they belong to (based on a third credential: companyCode (Login, Pass, companyCode) and put the related connectionstring in the Session.

In the global.asax is do this:

    protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
    {
        if(Session["cstr"]!=null)
        {
            XYZ.HelperClasses.DbUtils.ActualConnectionString = (string)Session["cstr"];
        }
    }

Now I would like to know if it is possbile that when 2 users connect for 2 companies at the same time the connectionstring get mixed up, so they will see the wrong data.

Also, if someone can advise me if this is a smart approach anyway, please do so. The situation is: 1 set of code files and 1 SQL Server with a database per client. Based on connectionstring the application presents the data.

Thank you!

Greets, Gab****

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 31-Oct-2005 15:04:08   

The question is what's the context of the "XYZ.HelperClasses.DbUtils.ActualConnectionString".

A suggestion is to use the session variable whenever it's needed. I mean retreive it everytime your going to access the database.