MySQL Forums
Forum List  »  Connector/ODBC

VBA connection to MySQL
Posted by: richard edwards
Date: February 20, 2009 05:37AM

I have created my connection MySQL with the following code:

Dim oConn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub ConnectDB()
Set oConn = New ADODB.Connection
oConn.Open "DRIVER={MySQL ODBC 5.1 Driver};" & _
"SERVER=localhost;" & _
"DATABASE=DATABASE1;" & _
"USER=USER1" & _
"PASSWORD=PASSWORD1;" & _
"Option=3"
End Sub

and am planning to extract the data with:

Private Sub PullData()
Set rs = New ADODB.Recordset
ConnectDB
strSQL = "select FIELD1, FIELD2, FIELD3 from DATABASE1.TABLE1 where FIELD4='xxx' order by date;"
'rs.Open strSQL, oConn, adOpenDynamic, adLockOptimistic
End Sub

i do not receive any errors when i run it so i presume all ok.

my questions are:
how do i pass the variable xxx from a cell in excel?
how do i even return this data into excel once i have it?

thanks very much all

richard

Options: ReplyQuote


Subject
Written By
Posted
VBA connection to MySQL
February 20, 2009 05:37AM
February 20, 2009 08:43AM
February 28, 2009 08:06PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.