By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,156 Members | 962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,156 IT Pros & Developers. It's quick & easy.

SQLConnection question

P: n/a
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
?

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net

Nov 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Why don't you create a new connection every time? Most driver has built-in
connection pooling already.

"bnob" wrote:
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
?

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net

Nov 19 '05 #2

P: n/a
Yes - don't make shared objects! Think about it, one connection for an
entire app - so of course if a second user tries to use it while the first
user is using it, you are going to have problems.

So solution is to not use global connection objects, or any object which
really needs to be per user.

"bnob" <bn**@bluewin.ch> wrote in message
news:mn***********************@bluewin.ch...
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
?

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net

Nov 19 '05 #3

P: n/a
So the solution is to create a connection object every time and close it
when the request is finished

I mean connections object that are per user.

"Marina" <so*****@nospam.com> a écrit dans le message de news:
#i**************@TK2MSFTNGP12.phx.gbl...
Yes - don't make shared objects! Think about it, one connection for an
entire app - so of course if a second user tries to use it while the first
user is using it, you are going to have problems.

So solution is to not use global connection objects, or any object which
really needs to be per user.

"bnob" <bn**@bluewin.ch> wrote in message
news:mn***********************@bluewin.ch...
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
?

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net


Nov 19 '05 #4

P: n/a
Yes, i would even say do it on a per method basis. That way you aviod
potential connection leaks.

"bnob" <ma**************@freesurf.ch> wrote in message
news:uM****************@TK2MSFTNGP09.phx.gbl...
So the solution is to create a connection object every time and close it
when the request is finished

I mean connections object that are per user.

"Marina" <so*****@nospam.com> a écrit dans le message de news:
#i**************@TK2MSFTNGP12.phx.gbl...
Yes - don't make shared objects! Think about it, one connection for an
entire app - so of course if a second user tries to use it while the first user is using it, you are going to have problems.

So solution is to not use global connection objects, or any object which
really needs to be per user.

"bnob" <bn**@bluewin.ch> wrote in message
news:mn***********************@bluewin.ch...
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 ?

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net



Nov 19 '05 #5

P: n/a
Ok but what about polling ?

Must I add paramters poll in the connection string ?

"Marina" <so*****@nospam.com> a écrit dans le message de news:
un*************@TK2MSFTNGP14.phx.gbl...
Yes, i would even say do it on a per method basis. That way you aviod
potential connection leaks.

"bnob" <ma**************@freesurf.ch> wrote in message
news:uM****************@TK2MSFTNGP09.phx.gbl...
So the solution is to create a connection object every time and close it
when the request is finished

I mean connections object that are per user.

"Marina" <so*****@nospam.com> a écrit dans le message de news:
#i**************@TK2MSFTNGP12.phx.gbl...
Yes - don't make shared objects! Think about it, one connection for an
entire app - so of course if a second user tries to use it while the first user is using it, you are going to have problems.

So solution is to not use global connection objects, or any object which really needs to be per user.

"bnob" <bn**@bluewin.ch> wrote in message
news:mn***********************@bluewin.ch...
> 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 > ?
>
> --
> Ceci est une signature automatique de MesNews.
> Site : http://www.mesnews.net
>



Nov 19 '05 #6

P: n/a
Polling? What does polling have to do with this? What is polling and for
what?

"bnob" <ma**************@freesurf.ch> wrote in message
news:ep**************@TK2MSFTNGP12.phx.gbl...
Ok but what about polling ?

Must I add paramters poll in the connection string ?

"Marina" <so*****@nospam.com> a écrit dans le message de news:
un*************@TK2MSFTNGP14.phx.gbl...
Yes, i would even say do it on a per method basis. That way you aviod
potential connection leaks.

"bnob" <ma**************@freesurf.ch> wrote in message
news:uM****************@TK2MSFTNGP09.phx.gbl...
So the solution is to create a connection object every time and close it when the request is finished

I mean connections object that are per user.

"Marina" <so*****@nospam.com> a écrit dans le message de news:
#i**************@TK2MSFTNGP12.phx.gbl...
> Yes - don't make shared objects! Think about it, one connection for an > entire app - so of course if a second user tries to use it while the

first
> user is using it, you are going to have problems.
>
> So solution is to not use global connection objects, or any object which > really needs to be per user.
>
> "bnob" <bn**@bluewin.ch> wrote in message
> news:mn***********************@bluewin.ch...
> > 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
> > ?
> >
> > --
> > Ceci est une signature automatique de MesNews.
> > Site : http://www.mesnews.net
> >
>
>



Nov 19 '05 #7

P: n/a
By chance did you mean "pooling"?

With SqlConnection and the SQL provider pooling happens by default.
You don't need to add any pooling parameters unless you want to turn
off pooling or adjust the number of connections in the pool.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 9 Dec 2004 20:14:12 +0100, "bnob"
<ma**************@freesurf.ch> wrote:
Ok but what about polling ?

Must I add paramters poll in the connection string ?

"Marina" <so*****@nospam.com> a écrit dans le message de news:
un*************@TK2MSFTNGP14.phx.gbl...
Yes, i would even say do it on a per method basis. That way you aviod
potential connection leaks.

"bnob" <ma**************@freesurf.ch> wrote in message
news:uM****************@TK2MSFTNGP09.phx.gbl...
> So the solution is to create a connection object every time and close it
> when the request is finished
>
> I mean connections object that are per user.
>
>
>
> "Marina" <so*****@nospam.com> a écrit dans le message de news:
> #i**************@TK2MSFTNGP12.phx.gbl...
> > Yes - don't make shared objects! Think about it, one connection for an
> > entire app - so of course if a second user tries to use it while the

first
> > user is using it, you are going to have problems.
> >
> > So solution is to not use global connection objects, or any objectwhich > > really needs to be per user.
> >
> > "bnob" <bn**@bluewin.ch> wrote in message
> > news:mn***********************@bluewin.ch...
> > > 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 amodule > > > (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 arealready > > > 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
> > > ?
> > >
> > > --
> > > Ceci est une signature automatique de MesNews.
> > > Site : http://www.mesnews.net
> > >
> >
> >
>
>



Nov 19 '05 #8

P: n/a
For you the best solution is to create a connection object every time and
close it
when the request is finished

I mean connections object that are per user.

"Scott Allen" <bitmask@[nospam].fred.net> a écrit dans le message de news:
16********************************@4ax.com...
By chance did you mean "pooling"?

With SqlConnection and the SQL provider pooling happens by default.
You don't need to add any pooling parameters unless you want to turn
off pooling or adjust the number of connections in the pool.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 9 Dec 2004 20:14:12 +0100, "bnob"
<ma**************@freesurf.ch> wrote:
Ok but what about polling ?

Must I add paramters poll in the connection string ?

"Marina" <so*****@nospam.com> a écrit dans le message de news:
un*************@TK2MSFTNGP14.phx.gbl...
Yes, i would even say do it on a per method basis. That way you aviod
potential connection leaks.

"bnob" <ma**************@freesurf.ch> wrote in message
news:uM****************@TK2MSFTNGP09.phx.gbl...
> So the solution is to create a connection object every time and close it > when the request is finished
>
> I mean connections object that are per user.
>
>
>
> "Marina" <so*****@nospam.com> a écrit dans le message de news:
> #i**************@TK2MSFTNGP12.phx.gbl...
> > Yes - don't make shared objects! Think about it, one connection for an > > entire app - so of course if a second user tries to use it while the first
> > user is using it, you are going to have problems.
> >
> > So solution is to not use global connection objects, or any object

which
> > really needs to be per user.
> >
> > "bnob" <bn**@bluewin.ch> wrote in message
> > news:mn***********************@bluewin.ch...
> > > 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
> > > ?
> > >
> > > --
> > > Ceci est une signature automatique de MesNews.
> > > Site : http://www.mesnews.net
> > >
> >
> >
>
>

Nov 19 '05 #9

P: n/a
Listen carefully: When you need to access the database (forget about "per
user"), open a Connection, do your business, and close the Connection.
Immediately. Always.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"bnob" <ma**************@freesurf.ch> wrote in message
news:#A**************@TK2MSFTNGP15.phx.gbl...
For you the best solution is to create a connection object every time and
close it
when the request is finished

I mean connections object that are per user.

"Scott Allen" <bitmask@[nospam].fred.net> a écrit dans le message de news:
16********************************@4ax.com...
By chance did you mean "pooling"?

With SqlConnection and the SQL provider pooling happens by default.
You don't need to add any pooling parameters unless you want to turn
off pooling or adjust the number of connections in the pool.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 9 Dec 2004 20:14:12 +0100, "bnob"
<ma**************@freesurf.ch> wrote:
Ok but what about polling ?

Must I add paramters poll in the connection string ?

"Marina" <so*****@nospam.com> a écrit dans le message de news:
un*************@TK2MSFTNGP14.phx.gbl...
> Yes, i would even say do it on a per method basis. That way you aviod> potential connection leaks.
>
> "bnob" <ma**************@freesurf.ch> wrote in message
> news:uM****************@TK2MSFTNGP09.phx.gbl...
> > So the solution is to create a connection object every time and close
it
> > when the request is finished
> >
> > I mean connections object that are per user.
> >
> >
> >
> > "Marina" <so*****@nospam.com> a écrit dans le message de news:
> > #i**************@TK2MSFTNGP12.phx.gbl...
> > > Yes - don't make shared objects! Think about it, one connection
for
an> > > entire app - so of course if a second user tries to use it while the> first
> > > user is using it, you are going to have problems.
> > >
> > > So solution is to not use global connection objects, or any
objectwhich
> > > really needs to be per user.
> > >
> > > "bnob" <bn**@bluewin.ch> wrote in message
> > > news:mn***********************@bluewin.ch...
> > > > 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
> > > > ?
> > > >
> > > > --
> > > > Ceci est une signature automatique de MesNews.
> > > > Site : http://www.mesnews.net
> > > >
> > >
> > >
> >
> >
>
>


Nov 19 '05 #10

P: n/a
Thats right Kevin..
Fast and Easy!
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.