Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Long wait query in Excel VBA

Posted on 2015-01-09
3
Medium Priority
?
197 Views
Last Modified: 2015-01-26
I have a long wait query in Excel VBA :

  Rs.Open stSQL, conn, adOpenKeyset, adLockReadOnly  (take 20 - 25mins)

Current, whole Excel may be grey out or white screen. Is it possible to improve give some progress for the result of the SQL connection status such that user will not abnormally end the VBA application,.. Tks
0
Comment
Question by:AXISHK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Assisted Solution

by:Simon
Simon earned 2000 total points
ID: 40542133
There are a number of possible reasons. You don't specify what your stSQL query string is, but it could be complex, returning millions of records. Performance will obviously also depend on the data source that you're connecting to. Is it a Microsft SQL Server or something else?

How long is the wait if you use a query that returns just one row from a single table?

Is a keyset type recordset necessary? If you are not updating the records, consider the default adOpenForwardOnly.

I'd suggest you refer to the ADO recordset.open documentation on MSDN, and experiment with the command and execute options.

If possible, check how long it takes to run the same query from another client (e.g. paste the SQL statement into the MS Access query builder) or use the Excel connection wizard to create your database connection and use your SQL statement in the properties tab. If the data source is an RDBMS and you have access to its management tools (e.g. SSMS), try the query directly from there. That also has the benefit of showing you the execution plan. You may be able to optimise your query or add indexes to dramatically improve performance.

Other useful sources for you to look at would be:
ADO performance best practices on Technet
SQLMag - VB Toolkit - Tweaking ADO for Performance
0
 

Author Comment

by:AXISHK
ID: 40543648
The query really take 20 min to complete, testing on the SQL Server Query window.

Just looking for a way to increase interaction on the Excel VBA, say the progress of the TSQL query for example, Tks
0
 
LVL 18

Accepted Solution

by:
Simon earned 2000 total points
ID: 40543820
Sorry, I mis-read your question.

I'd suggest you look at How To Use the ADO FetchProgress and FetchComplete Events on Microsoft Support, possibly in conjunction with a progress bars, possibly in conjunction with AlainByrden's VBA progress bar article.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

715 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