He sacado estos tres codigos:
Public cn As New rdoConnection
CadenaConnect = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=192.168.1.3;DATABASE=Garbatur;PWD=password;UID=root;OPTION=3"
cn.Connect = CadenaConnect
cn.CursorDriver = rdUseServer
cn.EstablishConnection
NOTA: (Proyecto->Referencia->Microsoft Remote Data Object 2.0)
Sub test()
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.ConnectionString = "Proveedor"
conn.CursorLocation = adUseClient
conn.Open
End Sub
Y esta otra:
Public con As Connection
Public STRCONEX As String
Public Function conectar()
On Error GoTo ERROR
Set con = New ADODB.Connection
STRCONEX = "DSN=;UID=ROOT;PWD=;"
con.ConnectionTimeout = 5
con.Open STRCONEX
Exit Function
ERROR:
MsgBox "Error en la conexion"
'con.ConnectionString = "driver={MySQL ODBC 3.51 Driver};server=localhost;uid=root;pwd=;database=;c onnection="
'con.Open
End Function