473,750 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with connection pooling - connections get closed but remain active

Can anyone see whats wrong with this code:

The connections are remaining live in the database: and causing
"Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool" errors.

Try
'open the connection
myConnection.Op en()
'run the query
myCommand.Execu teNonQuery()
Catch ex As SqlException

Finally
'close connection
myConnection.Cl ose()

End Try

'Check to see if the service is restricted
If
myCommand.Param eters("@AccessR estrictionsSupp orted").Value.E quals(1)
Then
Return True 'service is restricted
'myConnection.C lose()
Else
Return False 'service not restricted
'myConnection.C lose()
End If

myConnection.Cl ose()

Any help/suggestions very much appreciated

Thanks!!

Nov 19 '05 #1
2 1391
close the connection immediatly after the ExecuteNonQuery () method call. You
don't need the myConnection.Cl ose() at the bottom since the finally block
will always be executed. When you close a connection it returns to the
connection pool where it will be destroyed after an idle period of 4 to 7.5
minutes.

Where do you exactly get the time-outs?

Gabriel Lozano-Morán

<ca***@orange.n et> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
Can anyone see whats wrong with this code:

The connections are remaining live in the database: and causing
"Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool" errors.

Try
'open the connection
myConnection.Op en()
'run the query
myCommand.Execu teNonQuery()
Catch ex As SqlException

Finally
'close connection
myConnection.Cl ose()

End Try

'Check to see if the service is restricted
If
myCommand.Param eters("@AccessR estrictionsSupp orted").Value.E quals(1)
Then
Return True 'service is restricted
'myConnection.C lose()
Else
Return False 'service not restricted
'myConnection.C lose()
End If

myConnection.Cl ose()

Any help/suggestions very much appreciated

Thanks!!

Nov 19 '05 #2
Timeouts when users logon to system.

Checked in enterprise manager - process info and there are lots of
active connections to the stored procedure that this piece of code
executes.

Thanks for your help

Much appreciated

"Gabriel Lozano-Morán" <ga************ @no-spam.com> wrote in message news:<eN******* *******@TK2MSFT NGP10.phx.gbl>. ..
close the connection immediatly after the ExecuteNonQuery () method call. You
don't need the myConnection.Cl ose() at the bottom since the finally block
will always be executed. When you close a connection it returns to the
connection pool where it will be destroyed after an idle period of 4 to 7.5
minutes.

Where do you exactly get the time-outs?

Gabriel Lozano-Morán

<ca***@orange.n et> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
Can anyone see whats wrong with this code:

The connections are remaining live in the database: and causing
"Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool" errors.

Try
'open the connection
myConnection.Op en()
'run the query
myCommand.Execu teNonQuery()
Catch ex As SqlException

Finally
'close connection
myConnection.Cl ose()

End Try

'Check to see if the service is restricted
If
myCommand.Param eters("@AccessR estrictionsSupp orted").Value.E quals(1)
Then
Return True 'service is restricted
'myConnection.C lose()
Else
Return False 'service not restricted
'myConnection.C lose()
End If

myConnection.Cl ose()

Any help/suggestions very much appreciated

Thanks!!

Nov 19 '05 #3

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

Similar topics

13
1897
by: Larry | last post by:
Hi I have asp.net programs. I used a very simple data transfer method by using URLs ¡°First.aspx¡± contents a line to send data to the ¡°second.aspx¡± page, for
8
1942
by: Mauricio | last post by:
Hello, Currently we have an ASP.NET 2003 app running, on one function the app calls to a stored procedure to SQLServerONE, that stored procedure creates some TEMP tables with the results of a stored procedure that is remotely called con SQLServerTWO that generates TEMP tables that are used to return results. When we begin stress-testing the app issuing the same function from many clients at the same time and check the open connections...
2
2456
by: Jim Heavey | last post by:
How do I set up a Connection Pool? How can I look on the server and see how many connections are being used by my application? I am pretty sure that my application must be leaving connections open, because I begin to receive error message indicating that the system can not open a connection and I should check my connection pool, with me being the only one on the server, this should not really be a problem. I am not sure why I do not...
8
2157
by: Pierson C | last post by:
I am developing on a website that is utilizing SQL Server 2000. Shortly after deploying the site, we began having timeout issues due to the max connections. 1st instinct was to diligently tidy up our connections. We did so by encapsulating with the using statement. Ex: using (SqlConnection myConnection = new SqlConnectionConfigurationSettings.AppSettings))
18
3247
by: Rob Nicholson | last post by:
We're getting an occasional occurrence of the following error when two users try and open the same record in our ASP.NET app: "There is already an open DataReader associated with this Connection which must be closed first." As suggested, I was closing the connection in the Finally part of the outer Try but I wasn't closing the data reader as well so I assume that if the following happens, the above error could occur
3
10296
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database I use System.Data.Common.DBConnection and .DBCommand. How can I keep aware from connection losses (network not availeable, db-server not available...)? Are there any strategies to detect this broken connections, and how can I
2
1451
by: Dan D. | last post by:
Let me say first that I don't know much about .NET. We inherited an app from a group of developers and we have a second group of contractors working on the app. The first group set min=100 in the config file. Since there will only be about 15 users of the app we decided to see if we could lower that number. We reduced it from 100 to 60 then to 25. I was looking to see if any more than that number show up in sql server. In every instance...
16
2871
by: crbd98 | last post by:
Hello All, Some time ago, I implemented a data access layer that included a simple connectin pool. At the time, I did it all by myself: I created N connections, each connection associated with a worker thread that would execute the db commands. The pool was fixed and all the connections were created when the db access class was instantiated. The connections remained opened during the whole execution. If a connection was not available...
2
1926
by: Tony Johansson | last post by:
Hello! How does this connection pool function actually ? As I have been told is that when the connection is returned to the pool the connection to the database is still open. What you do is that you just return a still open connection to the pool. When I open a connection I get an already open connection to the database. Is this correct understood ?
0
8836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9575
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9338
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8260
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6803
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3322
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
2
2798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2223
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.