I'm having an issue connecting to my MySQL database from a VBA macro. (If this would be better served being asked in Stack Overflow, you can just tell me :) I have used this code

databasename = rando_db_name
Set oconn = New ADODB.Connection

oconn.Open "DRIVER={MySQL ODBC 5.1 Driver};" & _
"SERVER=xxx.xxx.xx.xxx;" & _
"DATABASE= " & databasename & ";" & _
"USER=test;" & _
" PASSWORD=rando_pw;" & _
"Option=3"

on a different computer in numerous other VBA programs, and it has worked fine. (The server is the IP of another computer at my desk; that's where all the databases are stored.) The problem is, trying to use the same code on a separate computer (my laptop) gives me the error message you see in the question title.It's preceded by [Microsoft][ODBC Driver Manager] if that helps at all.

Now, here's the thing I see as kind of odd- I know that I have a connection to the server, because I can open up Workbench (what I use for database management) and see and manipulate the databases, all from my laptop.

So to sum up, I guess I need to know, what is this error message telling me, why does this process work on one computer on the network and not another, and how can I fix it? Thank you for your time!

Quintis

link|improve this question

25% accept rate
Is there a DSN on the working machine? I'm assuming that's not the case but helps to eliminate the obvious ones first. – billinkc Nov 16 '11 at 15:32
How could I find that out? Sorry, I'm pretty new to databases in general... – Quintis555 Nov 16 '11 at 15:48
Start, Control Panel, Administrative Tools, Data Sources (ODBC). The base operating system on both machines is windows ? and can you tell me whether it's 32 or 64 bit? There are 2 of these Data Sources programs so that matters. Windows key, R brings up the Run dialog. Type dxdiag(click No when it asks about signed certs) Your Operating system line should be something like "Windows 7 Enterprise 64-bit" – billinkc Nov 16 '11 at 16:20
Sorry for the slow response, The machine with the server is running Windows 7 (32-bit) and the laptop that I'm trying to make connect is Windows 7 x64. As for the DSN, I followed your directions on both machines and both took me to a screen with a number of tabs, "User DSN," "System DSN," "File DSN," "Drivers," "Tracing," and "Connecting Pooling." In the User DSN tab it had "dBASE Files," "Excel Files" and "MS Access Database" listed. Is that the info you needed? Thank you! – Quintis555 Nov 17 '11 at 17:36
Check System and User DSN tabs on the server. You are looking for anything that lists the Driver as MySQL. If you find one on the server, I'd be dollars to dumplings that adding it to the laptop will make things work. It'll probably need to go in on the 32 version of ODBC driver. On the file system, it'll be approximately C:\Windows\WOW64\System32\odbcad32.exe I'm on XP 32 bit here so that's from memory. The GUI launches the odbcad32.exe that is in the windows\system32 folder even though it's the 64bit version of the driver. It sounds backwards but it's a backwards compatibility hack – billinkc Nov 17 '11 at 18:23
show 1 more comment
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.