Solved

excel 2007 vba mysql to array hangs

Posted on 2010-09-09
6
759 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 500 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

Technology Partners: 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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

730 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