Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have an Excel VBA application that connects to a SQL Server 2008 R2 database through ADODB.

When I'm on the network at work, the connection is almost instantaneous. When I am at home working with a local copy of the database, the connection takes about 5 seconds. At first I thought the performance hit had to do with the queries, and even posted a question on Stackoverflow with that incorrect assumption: http://stackoverflow.com/q/10467876/138938

The connection is just as slow locally whether I specify "localhost" or a ".". It seems like my code is having a hard time resolving where exactly my localhost is. Is there something I should do with my hosts file or some other setting that I can modify to speed up my connection on my local machine?

What other thing should I look at to troubleshoot?

Thanks!

share|improve this question
    
What protocols are enabled under SQL Server Configuration Manager? Try disabling Named Pipes and TCP/IP so that SQL Server must use Shared Memory. While you are local, are you also connected to your VPN? Is it possible that some kind of AD resolution is going on? –  Aaron Bertrand May 21 '12 at 16:43
    
Shared Memory, TCP/IP, Named Pipes and VIA were all enabled. I disabled all but Shared Memory without any luck. Do I need to bounce the server for it to take effect? I'm not connected to a VPN, but this machine has had issues. A full rebuild may be in order. –  Head of Catering May 21 '12 at 16:55
    
Yes you need to restart the service for those changes to take effect. –  Aaron Bertrand May 21 '12 at 16:59
    
Also is there any way to tell Excel to use SQL Native client instead of the slow and ancient ADODB? I don't use Excel VBA so I don't know if it's possible, but if it is you should explore that and test the difference... –  Aaron Bertrand May 21 '12 at 17:05
    
I'm at work now, so can't test. I'll get back on this tonight. Thanks! –  Head of Catering May 21 '12 at 19:13
show 2 more comments

1 Answer

If this is specific to that one database (you don't mention whether you can connect to other databases like master on localhost without issues), check if its Auto Close setting is True. If at work you're connecting to an instance of the DB that is constantly connected to by others as well, then the database will remain open and ready for use and respond faster. However, at home you will be the only user, and if you're not connected Auto Close will free resources relating to the database and close it, reducing its responsiveness next time you use it. The effect of this could be quite pronounced.

This option is False by default on most editions of SQL Server, but if your database was originally created using MSDE or SQL Express then those have it set to True by default.

share|improve this answer
    
Thanks for the suggestion. I'll take a look at that tonight or sometime this weekend. –  Head of Catering May 25 '12 at 18:11
    
I just checked -- Auto Close was set to False. –  Head of Catering May 29 '12 at 2:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.