http://connectionstrings.com/Mr Key,
Do you know how to set up an ODBC connection? I assume not.
I'm assuming the client is a windoze machine.
First, open the Control Panel.
If running Windows Xp, 7, or 8, open the "Administrative Tools".
Next, open "Data Sources" or "Data Sources (ODBC)".
Then you have to "Add" a data source. Which type "User DSN", or "System DSN" is up to you (and whether you have administrative control on the system).
It will give you a list of available data source types. Select the one for MySQL. If you do not have one for MySQL, you will have to install the appropriate driver first.
Once you've selected the data source type, a connection dialogue will display - populate it and test your connection.
Once you've got the data source set up, close out the control panel. Remember the name; I will use the string
"mySQL-DB" in the example, just to keep consistency. Also, for security reasons, I would suggest that you not store username and password as part of the perminant ODBC connection.
In Access, you create a database connection something like this:
-
-
''--establish the connection string
-
'' NOTE:
-
'' <username> is your database login username
-
'' <password> is your database login password
-
Dim dbODBC As String
-
Let dbODBC = "DSN=mySQL-DB;UID=<username>;PWD=<password>;"
-
-
''--connection object
-
Dim dbConn As ADODB.Connection
-
Set dbConn = New ADODB.Connection
-
-
''--attempt connection
-
dbConn.Open dbODBC
-
If dbConn.State = adStateOpen Then
-
dbConn.Close
-
MsgBox "Yay! Was able to connect!"
-
Else
-
MsgBox "Boo! Hiss! Failed to connect!" & Chr(10) & Err.Description
-
End If
-
-
This page on
ODBC Administration might be useful to you.
This page has a great deal of information on constructing
MySQL ODBC connection strings.
There are lots of code examples about the 'Net.
Kind Regards,
Oralloy