[AccessD] Connecting to MySQL across Internet **Anybody???**

MartyConnelly martyconnelly at shaw.ca
Thu Sep 16 12:12:38 CDT 2004


Roughly it would look like this
check for correct options or if driver name has changed for MYODBC and 
or using OLEDB version
from
http://dev.mysql.com/tech-resources/articles/vb-blob-handling.html

'CREATE CONNECTION OBJECT AND ASSIGN CONNECTION STRING
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection

conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
& "SERVER=127.0.0.1;" _
& "DATABASE=test;" _
& "UID=testuser;" _
& "PWD=12345;" _
& "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384

conn.CursorLocation = adUseClient
conn.Open


'OPEN RECORDSET FOR WRITING
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

rs.Open "SELECT * FROM TableName", conn, adOpenStatic, adLockOptimistic
-------------------
a program to test an app using MySQL. It uses ADO 2.5
on a MySQL server version 3.23.47.
Note - if the MySQL database is off-site (available through the internet),
default port 3306 must be open on the server/firewall.


Sub TestMySQL()
On Error Resume Next
Dim cn As New ADODB.Connection
Dim sql As String

'Set Connection String
cn.ConnectionString = "driver={MySQL ODBC 3.51 
Driver};server=xx.xxx.xxx.x;Port=xxxx;uid=user;pwd=passwrd;database=Phonebook"
cn.Open

'Add records to table
sql = "INSERT INTO Phonelist (ID, FName, LName, PhoneNum) VALUES" _
& "('" & txtID & "','" & txtFName & "','" & txtLName & "','" & txtPhone 
& "')"

cn.Execute sql

cn.Close

End Sub
---------------------------------------------------
Here are some sample or freebie programs that can test your remote 
connection to MySQL

Toad for MySQL – Preview Release
http://www.quest.com/ToadMySQL/index.asp

MyAccess MySQL type of EM for MySQL as an Access Addin
http://www.hiden.org/myaccess/

How to import Excel, Access or XML data into MySQL database by using a 
MySQL Client Tool – Navicat?
http://www.stardeveloper.com/articles/display.html?article=2003101901&page=1



Robert Gracie wrote:

>Hello,
> I have a program that may need to connect to a MySQL database across the
>internet, on the fly. It's only for a very small portion of the program so
>it may or may not be needed to be utilized by many users.
>
> So basically what is the best (lightest) way to make this connection on the
>fly, and only when needed? I think I will be looking at 3-4 tables MAX.
>
>
>To add,... it's an A2K .mdb
>
>Robert Gracie
>www.servicexp.com
>
>
>
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list