DIRECTION (2)
This is some VBA, run from the Access database:
Sub InsertRecs()
Set db = CurrentDb
'DSN=Suitable system DSN for MySQL
'Then, depending on your set up, you can incude:
'Database=DBName;
'Trusted_Connection=Yes;
'NameOfMySQLTable
strSQL = "INSERT INTO [ODBC;DSN=baywotch;].tblAuction Select * FROM tblAuction;"
db.Execute strSQL, dbFailOnError
End Sub
This is the same thing, but in VBScript, using DAO:
Dim objEngine
Dim objWS
Dim objDB
Dim db: db = "C:\Docs\baywotch.db5"
Set objEngine = wscript.CreateObject("DAO.DBEngine.36")
Set objDB = objEngine.OpenDatabase(db)
objDB.Execute "INSERT INTO [ODBC;DSN=baywotch].[tblAuction] SELECT * FROM tblAuction;"
DIRECTION (1)
I suggest a completely different direction, and that is to let MySQL do the work:
MySQL Migration Toolkit
I tested this against your database, and it appears to import correctly, only takes a few minutes, and will generate all sorts of reusable scripts and so on.
If you are having problems with the set-up of MySQL, you may wish to read:
9.1.4. Connection Character Sets and Collations
DiRECTION (0)
REWRITE (2)
'========================================================================'
'
' FROM: AnthonyWJones, see post '
'
'========================================================================'
Dim db: db = "C:\Docs\baywotch.db5"
Dim exportDir: exportDir = "C:\Docs\" '" SO prettify does not do VB well
Dim exportFile: exportFile=NewFileName(exportDir)
Dim cn: Set cn = CreateObject("ADODB.Connection")
cn.Open _
"Provider = Microsoft.Jet.OLEDB.4.0; " & _
"Data Source =" & db
cn.Execute "SELECT * INTO [text;HDR=Yes;Database=" & exportDir & _
";CharacterSet=65001]." & exportFile & " FROM tblAuction"
'Export file
'========================================================================'
'Support functions
Function NewFileName(ExportPath)
Dim fs
Dim NewFileTemp
Set fs = CreateObject("Scripting.FileSystemObject")
NewFileTemp = "CSV" & Year(Date) _
& Right("00" & Month(Date),2) & Right("00" & Day(Date) ,2) & ".csv"
a = fs.FileExists(ExportPath & NewFileTemp)
i = 1
Do While a
NewFileTemp = "CSV" & Year(Date) _
& Right("00" & Month(Date),2) & Right("00" & Day(Date) ,2) & "_" & i & ".csv"
a = fs.FileExists(ExportPath & NewFileTemp)
i = i + 1
If i > 9 Then
'Nine seems enough times per day to be
'exporting a table
a = True
MsgBox "Too many attempts"
WScript.Quit
End If
Loop
NewFileName = NewFileTemp
End Function