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

Home Posts Topics Members FAQ

Connection pooling issue with pass through queries

I'm creating an MS Access application that connects to a SQL Server
2005 database using pass-through queries and ADO to call stored
procedures. I ran a SQL trace and started clicking through various
forms to look at how things were being handled on the database. I
noticed an alarming number of connections were opened as if there was
absolutely no connection pooling. After several clicks I had 20 new
connections. It appeared that a new connection was being opened by
each pass-through query even though the connection strings are exactly
the same in each (I set them globally in code at application
startup). I also noticed that if I set my connection string to use a
SQL Server login (username/password) rather than a trusted connection,
the problem went away and connections were properly reused. Note that
calls to the database made via ADO did not exhibit this problem.
Also, I'm not using an ODBC DSN.

Is there a reason why I'm seeing this behavior? Is there a setting
somewhere that I've neglected to change?

Bill E.
Hollywood, FL
Jun 27 '08 #1
12 3145
Bill E. wrote:
I'm creating an MS Access application that connects to a SQL Server
2005 database using pass-through queries and ADO to call stored
procedures. I ran a SQL trace and started clicking through various
forms to look at how things were being handled on the database. I
noticed an alarming number of connections were opened as if there was
absolutely no connection pooling. After several clicks I had 20 new
connections. It appeared that a new connection was being opened by
each pass-through query even though the connection strings are exactly
the same in each (I set them globally in code at application
startup). I also noticed that if I set my connection string to use a
SQL Server login (username/password) rather than a trusted connection,
the problem went away and connections were properly reused. Note that
calls to the database made via ADO did not exhibit this problem.
Also, I'm not using an ODBC DSN.

Is there a reason why I'm seeing this behavior? Is there a setting
somewhere that I've neglected to change?

Bill E.
Hollywood, FL
Why are you worried about it? Have you had a single problem that you would
have noticed had you NOT used SQL trace?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jun 27 '08 #2
Rick,

That's almost like asking why we should bother with database
connection pooling. It's a question of efficient use of resources and
avoiding problems that may occur in production. I was one single user
clicking through one single form and opened over 20 connections.
That's just plain sloppy and unacceptable. Who knows how many
connections would be opened with many users working on a complete
application in extended sessions. It wasn't long ago that I had to
fix someone else's web application because it opened hundreds of
connections and stopped all users in their tracks when the number of
allowable connections was exceeded.

The problem is eliminated when I set the connection string to use a
SQL Server login instead of a trusted connection. Until I understand
what's going on here, I'm going to stick with that. Any insight into
what may be causing this would be welcomed.

Thanks,

Bill E.
Hollywood, FL
Jun 27 '08 #3
Bill E. wrote:
Rick,

That's almost like asking why we should bother with database
connection pooling. It's a question of efficient use of resources and
avoiding problems that may occur in production. I was one single user
clicking through one single form and opened over 20 connections.
That's just plain sloppy and unacceptable. Who knows how many
connections would be opened with many users working on a complete
application in extended sessions. It wasn't long ago that I had to
fix someone else's web application because it opened hundreds of
connections and stopped all users in their tracks when the number of
allowable connections was exceeded.

The problem is eliminated when I set the connection string to use a
SQL Server login instead of a trusted connection. Until I understand
what's going on here, I'm going to stick with that. Any insight into
what may be causing this would be welcomed.
I can only tell you that I have been using ODBC with trusted connections
with around 200 users for over a decade and have never once had an issue
with it.

Connections ARE re-used.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jun 27 '08 #4
In ADPs multiple connections cause problems when application roles are
used as per this quote from http://support.microsoft.com/kb/308312.

"Unlike with other database objects, Access does not always use the
same connection to retrieve the data source of a subform. Access
frequently (but not always) creates a new connection to SQL Server
just to handle the subform recordset, or to retrieve the linking field
data that connects the subform to the main form. Because this new
connection does not have the application role applied, a permissions
error may be generated if you do not have explicit permissions to the
database object. Unfortunately, this means that there is no reliable
way to use bound subforms when application roles are applied. The only
effective workaround is to have completely unbound subforms, with the
data manipulation handled programmaticall y. This is the most serious
limitation when using application roles in Access."

I believe that "Access frequently (but not always) creates a new
connection to SQL Server just to handle the subform recordset" is not
the whole story. In my experience Access frequently (but not always)
creates a new connection to SQL Server to handle any implicit Select,
Insert, Update or Delete procedure, including record-based combo-boxes
and list-boxes. It would be helpful if "not always" could be
documented as to when. I have found that "not always" is
unpredictable, varying from day-to-day and server to server.

I have never used application roles with ODBC and can't comment on
that combination.

A different kind of problem caused by multiple connections is the
effect they may have on the application's credibility. When a DBA/SA
sees one hundred five connections from the application to his server
when she knows only seventeen users have the application open he may
be alarmed. And she may communicate that alarm and concern for
efficiency, merited or not, to the people who are making decisions
about buying Access applications.

On May 31, 10:00*pm, "Rick Brandt" <rickbran...@ho tmail.comwrote:
Why are you worried about it? *Have you had a single problem that you would
have noticed had you NOT used SQL trace?
Jun 27 '08 #5
Lyle,

Thanks for the information. I'm not using an ADP and I'm not using
application roles, although I was considering it. I agree that it
would be helpful if it were documented somewhere how Access is
handling connections to SQL Server.

I found something else that was strange. It appeared that pass-
through queries were being called twice for some reason. That is to
say that my trace was showing two calls in a row to the same stored
procedure every time. However, when I ran a pass-through query
directly by clicking on the query and running it, the trace showed
only one call to the proc as expected. I thought perhaps the problem
was due to poor form design on my part. To test this, I created a
form with nothing but a single combobox and bound the combobox to the
pass through query. When I opened the form, I looked at my trace and
voila--two calls to the same proc on SQL Server! Do you have any idea
why this would be happening?

Bill
Jun 27 '08 #6
"Bill E." <bi********@net scape.netwrote in news:0ebc7349-14be-49e2-b40f-
f7**********@x1 g2000prh.google groups.com:
Lyle,

Thanks for the information. I'm not using an ADP and I'm not using
application roles, although I was considering it. I agree that it
would be helpful if it were documented somewhere how Access is
handling connections to SQL Server.

I found something else that was strange. It appeared that pass-
through queries were being called twice for some reason. That is to
say that my trace was showing two calls in a row to the same stored
procedure every time. However, when I ran a pass-through query
directly by clicking on the query and running it, the trace showed
only one call to the proc as expected. I thought perhaps the problem
was due to poor form design on my part. To test this, I created a
form with nothing but a single combobox and bound the combobox to the
pass through query. When I opened the form, I looked at my trace and
voila--two calls to the same proc on SQL Server! Do you have any idea
why this would be happening?

Bill
Not really! All I can think is that ODBC can translate a JET/VBA
expression, say, TRIM(x), to its T-SQL equivalent RTRIM(LTRIM(x)) [this is
not a good example] and perhaps, to do so it must visit the SQL Server
twice, once to assess and plan, and a second time to do the work. But I
think it doesn't attempt to do that with Pass Through Queries, it just
[passes them through].

[OT] I often create and maintain an independent ADO connection (as below)
when dealing with SQL Server and use it rather than
CurrentProject. Connection where ever possible. Depending on the version of
Access, one can use an ADO recordset for bound forms, and bypass the normal
methods of binding.

Dim mDefaultConnect ion As ADODB.Connectio n

Private Sub OpenConnection( ByRef Connection As ADODB.Connectio n)
Set Connection = New ADODB.Connectio n
With Connection
.CursorLocation = adUseClient
.Provider = "sqloledb.1 "
With .Properties
.Item("Data Source") = "Place_Hold er"
.Item("Initial Catalog") = "Place_Hold er"
-----
.Item("PassWord ") = "Place_Hold er"
.Item("User ID") = "Place_Hold er"
-----
OR
-----
..Item("Integra ted Security") = "SSPI"
-----
End With
.Open
End With
End Sub

Public Function DefaultConnecti on() As ADODB.Connectio n
If mDefaultConnect ion Is Nothing Then _
OpenConnection mDefaultConnect ion
Set DefaultConnecti on = mDefaultConnect ion
End Function

Public Function NewConnection() As ADODB.Connectio n
OpenConnection NewConnection
End Function

Jun 27 '08 #7
Here are some resources you can try -- It might help to set up ODBC
Trace to troubleshoot from that side. The optimizing paper listed
first explains how Jet works with SQL Server. Make sure to turn off
trace when you're done - it can really chew up resources. HTH.

Optimizing Microsoft Office Access Applications Linked to SQL Server
http://msdn.microsoft.com/en-us/library/bb188204.aspx

Data Access Tracing
http://msdn.microsoft.com/en-us/library/aa964124.aspx

How To Generate an ODBC Trace
http://support.microsoft.com/kb/274551

--Mary

On Sat, 31 May 2008 13:55:06 -0700 (PDT), "Bill E."
<bi********@net scape.netwrote:
>I'm creating an MS Access application that connects to a SQL Server
2005 database using pass-through queries and ADO to call stored
procedures. I ran a SQL trace and started clicking through various
forms to look at how things were being handled on the database. I
noticed an alarming number of connections were opened as if there was
absolutely no connection pooling. After several clicks I had 20 new
connections. It appeared that a new connection was being opened by
each pass-through query even though the connection strings are exactly
the same in each (I set them globally in code at application
startup). I also noticed that if I set my connection string to use a
SQL Server login (username/password) rather than a trusted connection,
the problem went away and connections were properly reused. Note that
calls to the database made via ADO did not exhibit this problem.
Also, I'm not using an ODBC DSN.

Is there a reason why I'm seeing this behavior? Is there a setting
somewhere that I've neglected to change?

Bill E.
Hollywood, FL
Jun 27 '08 #8
Bill E. (bi********@net scape.net) writes:
That's almost like asking why we should bother with database
connection pooling. It's a question of efficient use of resources and
avoiding problems that may occur in production. I was one single user
clicking through one single form and opened over 20 connections.
That's just plain sloppy and unacceptable. Who knows how many
connections would be opened with many users working on a complete
application in extended sessions. It wasn't long ago that I had to
fix someone else's web application because it opened hundreds of
connections and stopped all users in their tracks when the number of
allowable connections was exceeded.

The problem is eliminated when I set the connection string to use a
SQL Server login instead of a trusted connection. Until I understand
what's going on here, I'm going to stick with that. Any insight into
what may be causing this would be welcomed.
I have no idea of what might be going on. I can understand that
connections are not being resued - the typical reason is that they
are not closed properly. But why it would work with SQL authentication
and not Windows authentication, I don't know.

My guess it that when you changed the authentication, you changed something
more thar you did not tell us about.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jun 27 '08 #9
Thanks for your comments Lyle, Mary and Erland.

Lyle -- I'm not sure how much Jet is involved in this because I have
no queries that need to be translated. Everything is a pass through
to SQL Server. There are no linked tables in my application. I've
seen that technique you mentioned for the ADO connection, but I'm not
having any problems with ADO. It's the pass-through queries that are
the problem.

Mary--Thanks for the resources. The first article deals primarily
with querying SQL Server through linked tables so does not apply to my
case. I'm interested in seeing what the ODBC trace looks like and I'm
hoping that it will not simply be an academic exercise but will lead
me to some kind of corrective action.

Erland -- I changed the connection string only, nothing else.

Bill
Jun 27 '08 #10

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

Similar topics

3
14503
by: Harry | last post by:
Using Oracle 8i enterprise on win 2000 (sp3) Installed the standard configuration & whenever I make a connection it takes about 10 secs. It's running on a P1900 with 1gb Ram so no reason there for slowness. Once I'm connected the queries work pretty much instantanously but to connect using SQLPLUS, Toad, ODBC, OLEDB all take about 10...
0
4736
by: JWM | last post by:
I am trying to implement Oracle connection pooling for the following code, which was written by someone else. Here is my main question -- this java file creates code that is executed every hour, but once per week, the oracle server is brought down for backup. At that time, I get an error that looks like I have the wrong credentials for the...
1
5713
by: Lenny Shprekher | last post by:
Hi, I am getting issues that Oracle collecting opened sessions (connections) from my webservice using regular System.Data.OleDb.OleDbConnection object. I am guessing that this is connection pooling issue. Is there is any way to disable connection pooling for one particular .net webservice? Thanks, Leonid
7
2199
by: Mrinal Kamboj | last post by:
Hi , I am using OracleConnection object from Oracle ODP.net provider and following is the behaviour which i am finding bit strange : To start with my argument is based on followings facts : 1. Connection object is a reference type object . 2. All reference types are passed by reference even when done without using modifier like ref /...
16
2853
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...
20
7189
by: fniles | last post by:
I am using VB.NET 2003, SQL 2000, and SqlDataReader. As I read data from tblA, I want to populate tblB. I use SQLDataReader for both tables. I do not use thread. When I ExecuteReader on tblB, I get the error "There is already an open DataReader associated with this Connection which must be closed first." How can I fix this error ? For each...
20
3254
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how many connection has been used ? 2. If the maximum pool size has been reached, what happens when I call the method Open to open the connection ? Will I...
3
1738
by: Hahn, Thomas | last post by:
Hallo, I have an ASP.NET application with masterpages, skins and diffrent themes. The application works fine, but the performance is not realy good. If I load an ASPX file, which has no database connection, is the performance ok. ASPX file with one or more database queries have a answer time about 15 or 20 seconds. Each database query need...
9
377
by: Bill E. | last post by:
I'm creating an MS Access application that connects to a SQL Server 2005 database using pass-through queries and ADO to call stored procedures. I ran a SQL trace and started clicking through various forms to look at how things were being handled on the database. I noticed an alarming number of connections were opened as if there was...
4
2501
by: Bill E. | last post by:
Lyle, Thanks for the information. I'm not using an ADP and I'm not using application roles, although I was considering it. I agree that it would be helpful if it were documented somewhere how Access is handling connections to SQL Server. I found something else that was strange. It appeared that pass- through queries were being called...
0
7700
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...
0
7924
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. ...
0
8125
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...
1
7676
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
5219
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...
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...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
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.