473,569 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQLConnection question

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
10 1318
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
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.c h> 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
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.c h> 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
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******** ********@TK2MSF TNGP09.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.c h> 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
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.p hx.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******** ********@TK2MSF TNGP09.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.c h> 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
Polling? What does polling have to do with this? What is polling and for
what?

"bnob" <ma************ **@freesurf.ch> wrote in message
news:ep******** ******@TK2MSFTN GP12.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.p hx.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******** ********@TK2MSF TNGP09.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.c h> 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
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******** ********@TK2MSF TNGP09.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.c h> 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
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******** ********@TK2MSF TNGP09.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.c h> 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
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******** ******@TK2MSFTN GP15.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******** ********@TK2MSF TNGP09.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.c h> 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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4917
by: huzz | last post by:
I have a method that gets sqldatareader as shown below.. my question is how do i close the sqlconnection (objConn) object within this method? If i put the objconn.Close(); after the return then i get "Unreachable code detected" and if i close it before the return i get "Invalid attempt to FieldCount when reader is closed." When i refresh...
0
1724
by: Nayt Grochowski | last post by:
Does anyone see any problem with the loading a SqlConnection into the System.Web.HttpContextCurrent.Items collection in a Page's Constructor. Then Closing and Disposing of it the OnUnload method? Connection would not be "Opened" until it was actually used (this is handled by a common "Helper" class - similar to Microsoft's SqlHelper...
6
4298
by: goodstart123 | last post by:
For example, the following code works fine without SqlConnection. Any Answer to the question? string connectionString = "server=YourServer; uid=sa; pwd=YourPassword; database=ProgASPDotNetBugs"; // get records from the Bugs table string commandString = "Select BugID, Description from Bugs";
4
5172
by: The Coolest Dolphin | last post by:
Hi all, I have a question/problem concerning usage of my sqlconnection throughout my program. In my main form (frmMain) I defined an sqlconnection (I've set the connection public so that I can open & close the connection from everywhere in my app). My main form is an mdi parent which contains several mdi-childs. To open and close the...
13
4240
by: MuZZy | last post by:
Hi, Just wanted to make sure i get it right: consider this class: // =========== START CODE ============= class Test { private SqlConnection con = null; public void Connect() { con = new SqlConnection(SomeConnectionString);
11
2868
by: Bob | last post by:
In our new .NET web applications, we try to limit the use of SqlConnection to just one instance per page, even if there are multiple accesses to various queries. The thinking behind is that this reduces the need to getting and returning connections to the pool repeatedly if a page has multiple calls to the DB, and each one manages its own...
2
1867
by: StephenRichter | last post by:
I have SqlServer loaded on my w2k system. The freeby I just downloaded from MS. Within WebMatrix I created a database. called it "WebMatrix" In WebMatrix I connect to the database. server: (local) Windows authentication Database: WebMatrix
1
1816
by: jinfeng_Wang | last post by:
hi, I have a question about the difference between SqlConnection.IDisposable.Dispose() and SqlConnection.Dispose(). Both of them realize the function of releasing the connection to the ConnectionPool? Do they have the same effection source code? If they are different, who can tell me the differences? If they are same, why MS gives the...
4
3881
by: Victor | last post by:
Hi Guys I have a problem here. I want to improve the performance for a website. When I looked into the system, I have found that the system made the "SqlConnection Object" static. That mean only one SqlConnection object will be used. Can someone tell me is that a correct way to do? Does that affect the system performance? Cheers Victor
4
1694
by: =?Utf-8?B?dGhlIGZyaWVuZGx5IGRpc3BsYXkgbmFtZQ==?= | last post by:
Hello, I am planning to use three databases on the local SQL Server. DB1 will be for App1, DB2 for App2, and DB3 will hold tables, that both, App1 and App2 need to access. With applications I mean ASP.NET applications.
0
7697
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7968
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.