VB6 and MySQL Connection string

Di bawah adalah sebagai nota bagaimana untuk buat connection dari vb6 ke MySQL. 

'========================
'Database Connection Part
'========================
'Change to IP Address if not on local machine
'Make sure that you give permission to log into the
'server from this address
'Make sure that you d/l and install the MySQL Connector/ODBC 3.51 Driver 

Sub OpenConn(ByRef conn As ADODB.Connection)
 Dim strConnString As String
 On Error GoTo errCon
 strConnString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost; " & _
                 "DATABASE=mydb;UID=myUserId;PWD=myPassword;OPTION=16427"
 Set conn = New ADODB.Connection
 conn.ConnectionString = strConnString
 conn.CursorLocation = adUseClient
 conn.Open

 Exit Sub
errCon:
 MsgBox Err.Description
End Sub

Rujukan : 1. http://www.connectionstrings.com/mysql#p27, dan sini

Leave a Reply