Re:solution - Using Microsoft Access as a Front-end to MySQL
Here's the code for appending a local access table into a remote mysql server when a link table won't work (error #2006)
----------------------------
Dim localtablefield1 As String
Dim localtablefield2 As String
Dim localtablefield3 As String
Dim db As dao.Database
Dim tdf As dao.TableDef
Dim rs As dao.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("myaccesstable")
rs.MoveFirst
Do Until rs.EOF
localtablefield2 = rs!field1
localtablefield2 = rs!field2
localtablefield2 = rs!field3
myodbcconn = "Driver={MySQL ODBC 5.1 Driver};Server=xx.xx.xxx.xx;Port=3306;Database=mysqldatabase;User=myuser; Password=mypassword;Option=3;"
Dim adoConn As ADODB.Connection
Dim adoRS As ADODB.Recordset
Set adoConn = New ADODB.Connection
Set adoRS = New ADODB.Recordset
Dim strSql As String
strSql = "INSERT INTO mysqltable(mysqlfied1, mysqlfied2, mysqlfied3) VALUES ('" & localtablefield1 & "', '" & localtablefield2 & "', '" & localtablefield3 & "');"
adoConn.Open myodbcconn
adoRS.Open strSql, adoConn
Set adoRS = Nothing
Set adoConn = Nothing
rs.MoveNext
Loop
MsgBox ("INSERT COMPLETE")
----------------------------------
Hope this helps someone.
Dave
Subject
Views
Written By
Posted
72387
February 14, 2007 01:10PM
18906
July 08, 2007 05:10PM
14629
August 24, 2007 05:57AM
11435
February 06, 2008 01:16PM
7464
September 01, 2009 11:03AM
7701
March 02, 2009 06:09AM
8443
December 01, 2008 01:49PM
6214
May 15, 2009 08:45AM
6428
May 25, 2009 05:12PM
Re:solution - Using Microsoft Access as a Front-end to MySQL
6274
May 26, 2009 11:33AM
6613
April 03, 2009 02:44AM
5934
May 01, 2009 08:36PM
6083
May 02, 2009 04:37AM
6295
June 08, 2009 10:28AM
7818
June 09, 2009 04:02PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.