SQL database connection in Global.asax.vb  
Author Message
Lemon.oO0





PostPosted: .NET Framework Data Access and Storage, SQL database connection in Global.asax.vb Top

We have an application where users log in and set up a ConnectionString based on the login-info. As to now, we have used

Application.Contents("conn") = (strConnectionString)

in Global.asax.vb (Application_Start section) and then in the in the webforms we use

Dim con As New SqlClient.SqlConnection
con = New SqlClient.SqlConnection(Application("conn"))
con.Open()
......
......
con.close()

(Each user has their own sql database that they connect to using the same scripts.)

The question is: When many users are logged on at the same time, will the use of Application.Contents be a safe way to connect to each users own database or is there a possibility that users suddenly will try to establish a connection to a database that is not their own

Scenario: User1 logs in at 10:00 and establish a connection to his own database. At 10:05 User2 logs on and establish a connection to his database since Global.asax.vb is run again. Will User1 now use User2's connection so that he is actually woking on User2's database

Is there a better/safer way to do this connection in Global.asax.vb

Help much appreciated!!!!




.NET Development36  
 
 
Lemon.oO0





PostPosted: .NET Framework Data Access and Storage, SQL database connection in Global.asax.vb Top

Setting Session("conn") = (strConnectionString) in the Session_Start section and then use

Dim con As New SqlClient.SqlConnection
con = New SqlClient.SqlConnection(Session("conn"))
con.Open()
......
......
con.close()

might work better