0

I have one table, Checkinout in Ms Access, and I want to import all the data of that table to my SQL Server database Checkinout table, using VB 6.0:

This is my code. It is not working perfectly [is this irony?]

   For i = 1 To LstLog.ListItems.Count
       For j = 1 To LstLog.ColumnHeaders.Count - 1
           REC.Open "insert into xyz (EmpID, LogID,CheckTime,SensorID) Values ('" & _
               LstLog.ListItems(i).SubItems(j) & "','" & _
               LstLog.ListItems(i).SubItems(j) & "','" & _
               LstLog.ListItems(i).SubItems(j) & "','" & _
               LstLog.ListItems(i).SubItems(j) & "' )", CN, _
               adOpenStatic, adLockBatchOptimistic
       Next j
   Next i
4

2 回答 2

1

您可以DBConvert用于此目的。

DBConvert for Access 和 MySQL 迁移工具将 Microsoft Access 转换为 MySQL 服务器,将 MySQL 转换为 Access。

您可以参考此直接链接以供参考

http://dbconvert.com/convert-access-to-mysql-pro.php?DB=1

如果您想以编程方式执行此操作,

逐步方法:

http://en.kioskea.net/faq/7342-export-access-database-to-mysql

于 2013-04-24T05:31:20.990 回答
0

您使用了相同的子项目 ID。删除内部 for 循环,例如:

For i = 1 To LstLog.ListItems.Count
    REC.Open "insert into xyz (EmpID, LogID,CheckTime,SensorID) Values ('" & _
        LstLog.ListItems(i).SubItems(1) & "','" & _
        LstLog.ListItems(i).SubItems(2) & "','" & _
        LstLog.ListItems(i).SubItems(3) & "','" & _
        LstLog.ListItems(i).SubItems(4) & "' )", CN, _
        adOpenStatic, adLockBatchOptimistic
Next i
于 2013-04-24T15:38:38.693 回答