04-11-2009, 12:17 PM
Install MySQL ODBC driver in your computer first.
And then use connection string.
Example:
And then use connection string.
Example:
Code:
' To Connect to MySQL Database
' Before using this function, make sure MySQL ODBC 5.1 Driver is installed
Public Function MySQLConnect(Login)
Dim Connection, Recordset, SQL, ConnectionString, SQL1, SQL2
SQL1 = "UPDATE wuser SET password = 'password' where login = '"
SQL2 = "';"
SQL = SQL1 + Login + SQL2
Set Connection = CreateObject( "ADODB.Connection")
Set Recordset = CreateObject( "ADODB.Recordset")
'Connection.Open "DSN=mysql"
ConnectionString="DRIVER= {MySQL ODBC 5.1 Driver}; SERVER= Server Name; PORT=3306;DATABASE=Database Name; USER=user id; PASSWORD=password; OPTION=3;"
Connection.Open ConnectionString
Recordset.Open SQL,Connection
'If Recordset.EOF Then
' msgbox "No records returned."
'Else
'Do While NOT Recordset.Eof
'msgbox Recordset("ID")
'msgbox Recordset("LOGIN")
'msgbox Recordset("PASSWORD")
'Recordset.MoveNext
'End If
'Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
End Function