SQLConnection best way to use

  • Thread starter Thread starter bnob
  • Start date Start date
B

bnob

Im my ASP.net project I do a lot of connection to the SQL Server
Database. I use a global variabe for my connection declare in a module
(VB.Net code behind)

All is ok but when I start a form from the default page it takes 30
seconds to show the resultat of a select request

And when, during this 30 seconds, a another user want open a another
forms from the default page, I have an error : "Connection are already
open"

I think it 's because I use the connection variable globally.

Any idea to use the best way the connection object in a ASP.net project
?
 
Hi,

Store just connection string, create and open connection instance as late as
posible and close/dispose asap.
Don't worry of connection time penality - connection pooling will handle
this.
 
Yup . . and do all that operation thru a dataaccess layer - that way you'd
ensure that nobody breaks the rules.

Connection Pooling will work as long as the connection string is EXACTLY the
same - so put that in the config file and read it from there.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik





Miha Markic said:
Hi,

Store just connection string, create and open connection instance as late as
posible and close/dispose asap.
Don't worry of connection time penality - connection pooling will handle
this.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

bnob said:
Im my ASP.net project I do a lot of connection to the SQL Server
Database. I use a global variabe for my connection declare in a module
(VB.Net code behind)

All is ok but when I start a form from the default page it takes 30
seconds to show the resultat of a select request

And when, during this 30 seconds, a another user want open a another
forms from the default page, I have an error : "Connection are already
open"

I think it 's because I use the connection variable globally.

Any idea to use the best way the connection object in a ASP.net project
?
 
Back
Top