[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

excel 2007 vba mysql to array hangs

Posted on 2010-09-09
6
Medium Priority
?
774 Views
Last Modified: 2012-05-10
We have the used the following routine many times in our Excel 2007 vba to get the full record set from the mysql database to an array and it has always worked in the past.  Now when we try with the data base at just over 14,000 records (and about 65 columns in each record) Excel will hang on the statement  myArray = rs.GetRows().  We are using uwamp as the server with mysql at version 5.1.41.  Can anyone advise on why this may be occuring.

ConnectDB
Set rs = New ADODB.Recordset
sqlstr = "SELECT * FROM members ORDER BY account_lastname ASC, account_firstname ASC"
rs.Open sqlstr, conn, adOpenDynamic, adLockOptimistic

maxarow = 0
If Not rs.EOF Then
  myArray = rs.GetRows()
  maxacol = UBound(myArray, 1)
  maxarow = UBound(myArray, 2)
0
Comment
Question by:digital-servers
[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
  • 3
  • 2
6 Comments
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 2000 total points
ID: 33646571
digital-servers,

Try loading the latest ODBC connector for MySQL:
http://www.mysql.com/downloads/connector/odbc/

Additionally, if this worked fine before and the only difference now is the size of the data, I would check your indexes (explain plan for query) and see if that and/or your MySQL server configuration need to be tuned any.

Here is a nice reference:
3 Ways to Speed Up MySQL
by gr8gonzo - http:M_124884.html

Regards,

Kevin
0
 

Author Comment

by:digital-servers
ID: 33646611
I believe we have found a solution.

we added this line
rs.CursorLocation = adUseClient
right after the line
Set rs = New ADODB.Recordset

The command  "rs.CursorLocation = adUseClient"  caches the recordset rows on the local machine instead of the database server.  

The routine seems to work and Excel does not hang.  Transfer was quick with just a slight pause at   myArray = rs.GetRows() when stepping through the visual basic code.

0
 

Author Closing Comment

by:digital-servers
ID: 33646640
Issue is solved
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 33646677
Glad you found that.  Yes, figured the issue was in the query cache or other configuration settings on MySQL due to the size of the query now that your results have grown.  Nice simple solution, but I would still look to performance tune the query and MySQL so that as your data grows you don't see other issues ...

Best regards and happy coding,

Kevin
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 33650237
Thanks, digital-servers!
I appreciate the recognition for helping you in any way I could.

Best regards and happy coding,
Kevin
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

649 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