473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Re: Connection pooling issue with pass through queries

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 #1
4 2489
"Bill E." <bi********@netscape.netwrote in news:0ebc7349-14be-49e2-b40f-
f7**********@x1g2000prh.googlegroups.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 mDefaultConnection As ADODB.Connection

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

Public Function DefaultConnection() As ADODB.Connection
If mDefaultConnection Is Nothing Then _
OpenConnection mDefaultConnection
Set DefaultConnection = mDefaultConnection
End Function

Public Function NewConnection() As ADODB.Connection
OpenConnection NewConnection
End Function

Jun 27 '08 #2
On Sun, 1 Jun 2008 06:52:51 -0700 (PDT), "Bill E."
<bi********@netscape.netwrote:
>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?
For forms and reports bound to passthrough queries, Access runs the
query *before* the Open event, then again during it's normal time. I
think this is because Access must get the column definitions "on the
fly" and must run the query to do so.

To mitigate this performance hit, we often add change the Where clause
of the passthrough query to WHERE 1=0 when the form or report
*closes*. This leaves it lurking until next time the object is used,
and results in a very fast query execution. Then in our Open event,
we change the Where clause to something more useful, often based on
user input. Using this technique we've seen performance improve from
several seconds down to instantaneous.

I've seen a variation on this technique where the lurking Where clause
is something like WHERE CustomerID = -1, which will result in zero
records. This isn't as quick, because SQL must still perform the
search. Using WHERE 1=0 is determined mathematically to be false, so
SQL immediately returns an empty recordset.

Hope this helps,

Armen Stein
Microsoft Access MVP
www.JStreetTech.com

Jun 27 '08 #3
I also you another technique - I clear form's recordsource property and set
it in form's Open event
Sometimes even WHERE 1=0 takes some time run

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
"Armen Stein" <Ar********@R3m00v3Th1s.gmail.comwrote in message
news:lo********************************@4ax.com...
On Sun, 1 Jun 2008 06:52:51 -0700 (PDT), "Bill E."
<bi********@netscape.netwrote:
>>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?

For forms and reports bound to passthrough queries, Access runs the
query *before* the Open event, then again during it's normal time. I
think this is because Access must get the column definitions "on the
fly" and must run the query to do so.

To mitigate this performance hit, we often add change the Where clause
of the passthrough query to WHERE 1=0 when the form or report
*closes*. This leaves it lurking until next time the object is used,
and results in a very fast query execution. Then in our Open event,
we change the Where clause to something more useful, often based on
user input. Using this technique we've seen performance improve from
several seconds down to instantaneous.

I've seen a variation on this technique where the lurking Where clause
is something like WHERE CustomerID = -1, which will result in zero
records. This isn't as quick, because SQL must still perform the
search. Using WHERE 1=0 is determined mathematically to be false, so
SQL immediately returns an empty recordset.

Hope this helps,

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
Jun 27 '08 #4
On Fri, 13 Jun 2008 09:49:22 +0400, "Alex Dybenko"
<al*****@PLEASE.cemi.NO.rssi.SPAM.ruwrote:
>I also you another technique - I clear form's recordsource property and set
it in form's Open event
Sometimes even WHERE 1=0 takes some time run
Hi Alex,

Yes, that will work too. But it's a hassle for the developer to have
a missing recordsource when it's time to make changes to the form.

WHERE 1=0 takes *some* time, but we've seen it to be almost instant.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com

Jun 27 '08 #5

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

Similar topics

3
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...
0
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,...
7
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 : ...
16
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...
20
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...
20
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...
3
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...
9
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...
3
by: Bill E. | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.