Solved

Timeout expired elapsed prior to obtaining a connection from the pool Winforms App

Posted on 2016-10-05
7
45 Views
Last Modified: 2016-10-31
I am getting the timeout expired elapsed prior to obtaining a connection from the pool error on a winforms app compiled on VS2010 .net 4.  I don't get this error on every computer using the program though.  I can run the same process and only get this error on 2 out of 10 computers or so.  All computers run remote, windows 7-10.  SQL server 2008.  I can't find any rim or reason to which ones work or don't work.  I am using use statements in the code.  What could I look for on the machines.  I have 2 computers in one office, one works one doesn't.  Both windows 10 64 bit.  Same fire wall, and antivirus settings.

Any suggestions on what I might be missing.
0
Comment
Question by:PDIS
7 Comments
 
LVL 20

Expert Comment

by:Russ Suter
ID: 41830198
What is your timeout set at? If you increase it does the problem go away? This might help determine whether you have a slow connection or something is just flat blocking things.
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 41830324
Also are you running sql express or an actual copy of sql?  Could be concurrent connections if you're running express.

Can you ping the sql server / connect to it from management studio when you get the time out?
0
 

Author Comment

by:PDIS
ID: 41830409
I moved the timeout to 120 seconds,  Based on screen updates it is processing when I get the pooling error.

Actually copy of SQL server 2008 STD.  I can still ping and connect when I get the timeout/pooling message.  I have even increases the number of pools to 200, just to see if it would finish.

I have a couple computers that will consistently get the error.  .net4 frame work.  Does it matter if or what very of the native sql client is installed.  From all my research, .net uses it own system.data.dll

Then I can run the same process on the same data on a different machine and it works just fine.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 41830599
Are you closing and disposing of the connections?  It could be more a matter of garbage collection?
0
 
LVL 12

Accepted Solution

by:
funwithdotnet earned 500 total points
ID: 41830992
I think Kyle might be correct. Are you using the 'Using' statement for System.Data.SqlClient.SqlConnection and System.Data.SqlClient.SqlCommand?

            Using myConnection As SqlConnection = New SqlConnection(connectionString)
                Using myCommand As New SqlCommand(queryCommandString, myConnection)
                    Try
                        ' execute commands

                    Catch ex As Exception

                    End Try
                End Using
            End Using 

Open in new window

0
 

Author Comment

by:PDIS
ID: 41844994
Kyle and funwithdotnet, I noticed not all places where using, using statements.  I took over the code from someone else, and I guess I didn't dig far enough.  Thank out for pointing in the right direction.  I do have a question, that we I search on everyone has a dinner opinion on.
                                                Try
                                                    Using conn As New SqlConnection(My.Settings.connStr)
                                                        Using cmd As New Data.SqlClient.SqlCommand(sqlSalesInsert, conn)
                                                            conn.Open()
                                                            cmd.ExecuteNonQuery()
                                                        End Using
                                                    End Using
                                                Catch ex As Exception
                                                End Try

Open in new window


This method or funs method which is actually better?
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 41845854
If you need access the variables inside the using statement then try inside of the using statement is your only option.  (EG: Once you leave the using the variables become out of scope).

If you don't need access to the variables then outside is fine.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now