473,654 Members | 3,040 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

timeout exception

I have a vb.NET solution with a Windows Application project that contains my user interface and a Class Library project that contains (among other things) a class I call DataAccessCompo nent. This class inherits from System.Componen tModel.Componen t and contains a single SQLConnection object and a bunch of SQLDataAdapter object which reference it. It also exposes 2 methods per SQLDataAdapter object that all look more or less the same. For example

Public Function GetOrganization s(
Optional ByVal anOrganizationI D As Object = Nothing) As dsNutme
Dim organizations As New dsNutme

organizations.E nforceConstrain ts = Fals
If Not anOrganizationI D Is Nothing The
SQLDAtblOrganiz ation.SelectCom mand.Parameters ("@Organization ID").Value = CType(anOrganiz ationID, Long
Els
SQLDAtblOrganiz ation.SelectCom mand.Parameters ("@Organization ID").Value = System.DBNull.V alu
End I
SQLDAtblOrganiz ation.Fill(orga nizations
Return organization
End Functio

Public Function UpdateOrganizat ions(ByVal organizationCha nges
As dsNutmeg) As dsNutme
If Not (organizationCh anges Is Nothing) The
SQLDAtblOrganiz ation.Update(or ganizationChang es
Return organizationCha nge
Els
Return Nothin
End I
End Functio

My question (and I DO have one), is this: why, after several "get" calls, for exampl

Private Sub GetDat

dim mDAC as New DataAccessCompo nen
dim ds as new dsNutme

ds.Merge(mDAC.G etOrganizations ()

' Do something with the data

End Su

, am I suddenly getting a timout exception with the advice that it might have somtehing to do with exceeding the available connections in my connection pool? I BELIEVED that I was just repeatedly using the same connection. Is this not the case? Am I not releasing connection resources properly? How SHOULD I go about doing what I'm trying to do

Thanks

Pa

Nov 20 '05 #1
9 2880
Hi Pat,

See this text on the page I give the link beneath it.
Note that the code does not explicitly open and close the Connection. The
Fill method implicitly opens the Connection that the DataAdapter is using if
it finds that the connection is not already open. If Fill opened the
connection, it will also close the connection when Fill is finished. This
can simplify your code when dealing with a single operation such as a Fill
or an Update. However, if you are performing multiple operations that
require an open connection, you can improve the performance of your
application by explicitly calling the Open method of the Connection,
performing the operations against the data source, then calling the Close
method of the Connection. You should strive to keep connections to the data
source open for a minimal amount of time to free up the resource to be used
by other client applications.

http://msdn.microsoft.com/library/de...ataadapter.asp

As well I looked at your update just to make you aware on it.
Public Function UpdateOrganizat ions(ByVal organizationCha nges _
As dsNutmeg) As dsNutmeg
If Not (organizationCh anges Is Nothing) Then
SQLDAtblOrganiz ation.Update(or ganizationChang es)
Return organizationCha nges
Else
Return Nothing
End If
End Function

In my opinion is that the same as
Public Sub UpdateOrganizat ions(ByVal organizationCha nges _
AS dsNutMeg)
If Not (organizationCh anges Is Nothing) Then
SQLDAtblOrganiz ation.Update(or ganizationChang es)
End Sub

Cor
Nov 20 '05 #2
Thanks for the response. I changed my "Get" procedures to explicitly open and close the connection object for each fill, but no joy. I still get the following message after a number of successful (say ca. 100) connections

"An unhandled exception of type 'System.Invalid OperationExcept ion' occurred in system.data.dl

Additional information: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.

The new "Get" method format is reproduced below

Public Function GetOrganization s(
Optional ByVal anOrganizationI D As Object = Nothing) As dsNutme
Dim organizations As New dsNutme

organizations.E nforceConstrain ts = Fals
If Not anOrganizationI D Is Nothing The
SQLDAtblOrganiz ation.SelectCom mand.Parameters ("@Organization ID").Value = CType(anOrganiz ationID, Long
Els
SQLDAtblOrganiz ation.SelectCom mand.Parameters ("@Organization ID").Value = System.DBNull.V alu
End I
SQLConnNutmegDa ta.Open(
SQLDAtblOrganiz ation.Fill(orga nizations
SQLConnNutmegDa ta.Close(
Return organization
End Functio

I've tried using PerformanceCoun ters to examine the state of my connection pool. Either I'm using them incorrectly, or that is not the problem because at no time do they show my # of pools or my # of pooled connections > 3. Incidentally, the statistics do not appear to be sensitive to whether I explicitly open and close my connection or not.

I have no idea how to proceed, but obviously the situation is unacceptable as it stands -- the user has to frequently exit and re-enter the application

BTW, the "update" format was copied right out of a Microsft walkthrough for setting-up a webservice. I didn't even really examine it until you pointed out the fact that the return value was unnecessary. I agree with you, OTOH, why did MS think that it was necessary in the walkthrough

Thanks again, and ANY advice would be MUCH appreciated

Pat
Nov 20 '05 #3
Hi Pat,

Angel says always to use dispose for the connection instead the close with
more than 100 connections.

There seems, with the connection, to be something extra under the hood that
the team who build that has used, however from the way he write that, I
always get the idea they are not really happy with it, and therefore they
changed it for the next version. However, you can give it a try.

Cor
Nov 20 '05 #4
Hmm. I tried the following scheme

dim connString as String=myConnec tionString
dim conn as SQLClient.SQLCo nnection
dim SQLDA as SQLClient.SQLDa taAdapter

if len(conn.Connec tionString)=0 then
conn=New SqlClient.SQLCo nnection(connSt ring)
SQLDA.SelectCom mand.Connection =conn
end if
conn.Open
SQLDA.Fill(ds)
conn.Close

The results were the same as when I simply used

SQLDA.Fill(ds)

and allowed the DataAdapter to implicitly open and close the connection.
--
Pat
"Cor Ligthert" wrote:
Hi Pat,

Angel says always to use dispose for the connection instead the close with
more than 100 connections.

There seems, with the connection, to be something extra under the hood that
the team who build that has used, however from the way he write that, I
always get the idea they are not really happy with it, and therefore they
changed it for the next version. However, you can give it a try.

Cor

Nov 20 '05 #5
Hi Pat,

I do not if it helps, however what I meant in my last message was to change
it in (see the last row inline).
dim connString as String=myConnec tionString
dim conn as SQLClient.SQLCo nnection
dim SQLDA as SQLClient.SQLDa taAdapter

if len(conn.Connec tionString)=0 then
conn=New SqlClient.SQLCo nnection(connSt ring)
SQLDA.SelectCom mand.Connection =conn
end if
conn.Open
SQLDA.Fill(ds)

conn.Dispose

Can you try it?

Cor
Nov 20 '05 #6
Woops. In fact I meant to write conn.Dispose. This seems to have no effect. I have also tried altering the Connection Timeout and the Max Pool Size in the connection string. Changing the Connection Timeout produces no discernable effect, but changing the Max Pool Size produces predictable results: increasing the Max Pool Size increases the number of connections I can make before the whole thing blows up, decreasing it does the opposite. Still, this does not actually solve the problem, it merely covers it up for a little while longer.

Also, as I said before, the whole thing is wrapped up in a Class I call DataAccessCompo nent. It does not seem to help if I instantiate a New DataAccessCompo nent each time I want to connect to the datasource.

Clearly I am grabbing connections out of the pool and not realsing them back into it, but how? Doesn't DISPOSE release them? If not, wouldn't Disposing the DataAccessCompo nent release them? What else can I dispose :-).

Thanks,

--
Pat
"Cor Ligthert" wrote:
Hi Pat,

I do not if it helps, however what I meant in my last message was to change
it in (see the last row inline).
dim connString as String=myConnec tionString
dim conn as SQLClient.SQLCo nnection
dim SQLDA as SQLClient.SQLDa taAdapter

if len(conn.Connec tionString)=0 then
conn=New SqlClient.SQLCo nnection(connSt ring)
SQLDA.SelectCom mand.Connection =conn
end if
conn.Open
SQLDA.Fill(ds)

conn.Dispose

Can you try it?

Cor

Nov 20 '05 #7
Hi Pat

Can you change it to this, I see for your other commands no reasons and I
see as well your SQL string anymore in your code. Bassicly is this all you
need.

\\\
dim conn as New SQLClient.SQLCo nnection(myConn ectionString)
dim SQLDA as new SQLClient.SQLDa taAdapter(sqlst ring, conn)
conn.Open
SQLDA.Fill(ds)
conn.Dispose
///
Woops. In fact I meant to write conn.Dispose. This seems to have no effect. I have also tried altering the Connection Timeout and the Max Pool
Size in the connection string. Changing the Connection Timeout produces no
discernable effect, but changing the Max Pool Size produces predictable
results: increasing the Max Pool Size increases the number of connections I
can make before the whole thing blows up, decreasing it does the opposite.
Still, this does not actually solve the problem, it merely covers it up for
a little while longer.
Also, as I said before, the whole thing is wrapped up in a Class I call DataAccessCompo nent. It does not seem to help if I instantiate a New
DataAccessCompo nent each time I want to connect to the datasource.
Clearly I am grabbing connections out of the pool and not realsing them back into it, but how? Doesn't DISPOSE release them? If not, wouldn't
Disposing the DataAccessCompo nent release them? What else can I dispose :-).
Thanks,

--
Pat

dim connString as String=myConnec tionString
dim conn as SQLClient.SQLCo nnection
dim SQLDA as SQLClient.SQLDa taAdapter

if len(conn.Connec tionString)=0 then
conn=New SqlClient.SQLCo nnection(connSt ring)
SQLDA.SelectCom mand.Connection =conn
end if
conn.Open
SQLDA.Fill(ds)

conn.Dispose

Can you try it?

Cor

Nov 20 '05 #8
Thanks Cor.

Yes, this is much more streamlined. As it turns out, I solved my problem, and it had nothing to do with any of this. I went to the Project Properties>>Con figuration Properties page and unchecked SQL Server debugging. Apparently, with SQL Server debugging enabled, the connections are not returned to the pool properly regardless of disposal. This seemed to clear up my problem, though it probably will have some other unintended side-effects :-). Thanks again for the help.

Pat
--
Pat
"Cor Ligthert" wrote:
Hi Pat

Can you change it to this, I see for your other commands no reasons and I
see as well your SQL string anymore in your code. Bassicly is this all you
need.

\\\
dim conn as New SQLClient.SQLCo nnection(myConn ectionString)
dim SQLDA as new SQLClient.SQLDa taAdapter(sqlst ring, conn)
conn.Open
SQLDA.Fill(ds)
conn.Dispose
///
Woops. In fact I meant to write conn.Dispose. This seems to have no

effect. I have also tried altering the Connection Timeout and the Max Pool
Size in the connection string. Changing the Connection Timeout produces no
discernable effect, but changing the Max Pool Size produces predictable
results: increasing the Max Pool Size increases the number of connections I
can make before the whole thing blows up, decreasing it does the opposite.
Still, this does not actually solve the problem, it merely covers it up for
a little while longer.

Also, as I said before, the whole thing is wrapped up in a Class I call

DataAccessCompo nent. It does not seem to help if I instantiate a New
DataAccessCompo nent each time I want to connect to the datasource.

Clearly I am grabbing connections out of the pool and not realsing them

back into it, but how? Doesn't DISPOSE release them? If not, wouldn't
Disposing the DataAccessCompo nent release them? What else can I dispose :-).

Thanks,

--
Pat

> dim connString as String=myConnec tionString
> dim conn as SQLClient.SQLCo nnection
> dim SQLDA as SQLClient.SQLDa taAdapter
>
> if len(conn.Connec tionString)=0 then
> conn=New SqlClient.SQLCo nnection(connSt ring)
> SQLDA.SelectCom mand.Connection =conn
> end if
> conn.Open
> SQLDA.Fill(ds)
conn.Dispose

Can you try it?

Cor


Nov 20 '05 #9
I think I see whay you might want to return the dataset from the update method. If you have checked the "Refresh the DataSet" option in the Advanced SQL Generation Options of the Data Adapter coniguration wizard, I believe returning the dataset will allow you to retrieve the (possibly) new PK values. I haven't verified this yet, but it makes sense.
--
Pat
"Cor Ligthert" wrote:
Hi Pat,

See this text on the page I give the link beneath it.
Note that the code does not explicitly open and close the Connection. The
Fill method implicitly opens the Connection that the DataAdapter is using if
it finds that the connection is not already open. If Fill opened the
connection, it will also close the connection when Fill is finished. This
can simplify your code when dealing with a single operation such as a Fill
or an Update. However, if you are performing multiple operations that
require an open connection, you can improve the performance of your
application by explicitly calling the Open method of the Connection,
performing the operations against the data source, then calling the Close
method of the Connection. You should strive to keep connections to the data
source open for a minimal amount of time to free up the resource to be used
by other client applications.

http://msdn.microsoft.com/library/de...ataadapter.asp

As well I looked at your update just to make you aware on it.
Public Function UpdateOrganizat ions(ByVal organizationCha nges _
As dsNutmeg) As dsNutmeg
If Not (organizationCh anges Is Nothing) Then
SQLDAtblOrganiz ation.Update(or ganizationChang es)
Return organizationCha nges
Else
Return Nothing
End If
End Function

In my opinion is that the same as
Public Sub UpdateOrganizat ions(ByVal organizationCha nges _
AS dsNutMeg)
If Not (organizationCh anges Is Nothing) Then
SQLDAtblOrganiz ation.Update(or ganizationChang es)
End Sub

Cor

Nov 20 '05 #10

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

Similar topics

7
40705
by: Pietje de kort | last post by:
Hello all, I am trying to build a class that does something, and may timeout while doing so. Ofcouse I want to be a bit elegant, so I came up with the code found below. Problem is, I can't catch the exception thrown on timeout. Anybody knows how to correctly implement timeout behaviour? Best regards, Wouter van Vugt
4
5507
by: Anders Borum | last post by:
Hello! I am working on improving my threading skills and came across a question. When working with the ReaderWriterLock class, I am getting an unhandled exception if I acquire a WriterLock with a timeout less than the time required to process the code section it protects. The code listed below is just a small application I wrote to check the behavious of the different threading / synchronization techniques. Basically the application...
1
3397
by: ArunPrakash | last post by:
Hi, I want to implement a method which will poll database for messages. But i want to provide a method that will specify a timeout until which it will be polled and after that it will throw an exception. I tried the following code. Here say for example GetString in class test is a method for which i want to provide timeout. Class1 contains the console application's main method
5
13269
by: Jason | last post by:
Hi all I get the following error when executing a rather intense stored procedure from an ASPX page. I have tried: - Increasing timeouts on IIS 5.0 (all areas that even mention timeout) - use the "Connection Timeout=2400" string in the SqlConnection connections string - disabled connection pooling.
2
4577
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET Here's the scenario: 1. .NET Windows Client on a remote machine makes a web service call to update tables on a Web Server running SQL Server 2000. 2. The Update is updating about 1000 - 3000 records doing simple update statements like "Update...
3
13977
by: Nils Magnus Englund | last post by:
Hi, I've made a HttpModule which deals with user authentication. On the first request in a users session, it fetches data from a SQL Server using the following code: using (SqlConnection connection = new SqlConnection(ConfigurationSettings.AppSettings)) {
4
13176
by: VB Programmer | last post by:
When I run my ASP.NET 2.0 web app on my dev machine it works perfect. When I precomile it to my web deployment project and then copy the debug files to my web server I get this problem when trying to login (obviously it's using ASPNETDB.mdf). Any ideas? Server Error in '/' Application. --------------------------------------------------------------------------------
7
9919
by: dadocsis | last post by:
I have a custom VB.net application that runs a query against an SQL server that takes more than 3 minutes. Right now after 3 minutes it times out. So far after doing my research I have changed the following: in web.config: <system.web> <httpRuntime executionTimeout="1000" maxRequestLength="2000000"/> <sessionState mode="InProc"
22
5279
by: Nick Craig-Wood | last post by:
Did anyone write a contextmanager implementing a timeout for python2.5? I'd love to be able to write something like with timeout(5.0) as exceeded: some_long_running_stuff() if exceeded: print "Oops - took too long!"
1
5165
by: Scorpion657 | last post by:
Hey I really need help. I have a Website coded using ASP.NET and VB and for some reason, i'm getting the following error when I try to upload or access a large file which is stored in the database. It was working fine when I was runing the site on the localhost. I added the following line to the web.config file to increase the timeout: <httpRuntime maxRequestLength="1048576" executionTimeout="3600"/> I also added: connection timeout =...
0
8375
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7306
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...
0
5622
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();...
0
4149
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
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.