I was using ADODB code in Windows to fetch data from Mysql Database and it was working fine. However, I can not seem to get my Excel workbook (using ADODB) to work with Excel Mac 2011. After a lot of googling, I found an ODBC connector from Actual tech and I was able to fetch three rows using Microsoft Query. But I want this to be done using VBA code but have been unable to do so. Has anyone gotten this to work? If yes, can you please provide me with a sample code. Thanks in Advance !!
P.S: I know there is a similar existing question but the link provided in the answer is no longer working. hence, I have asked a new question
Also, If anyone needs the link to do it through Microsoft Query, here is the link: http://www.agentjim.com/MVP/Excel/2011Relational7Queries.html
Here is the code I use in Windows:
Sub getMysqlDBdata()
Dim Cn As Object
Dim sqlQa as string
dim temparray1 as variant
Source = "MySQL"
mysql_driver = "MySQL ODBC 5.2 ANSI Driver"
sqlQa = "select * from test.TestTable;"
Set Cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
Cn.Open "Driver={" & "MySQL ODBC 5.2 ANSI Driver" & "};Server=" & "127.0.01" & ";Database= test;UID=" & "root" & ";PWD=" & "12345"
rs.Open sqlQa, Cn, adOpenStatic
temparray1 = rs.GetRows()
rs.Close
Set rs = Nothing
End Sub
After a lot of googling I came across this sample code provided by Bryan Duchesne in MSDN: