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
1
  • I think you can create ODBC connections to each database and then use them in your program to transfer data from one to the other... But I must ask, what have you tried so far? Commented Apr 24, 2013 at 5:18

2 Answers 2

1

You can use DBConvert for this purpose.

DBConvert for Access and MySQL migration tool converts Microsoft Access to MySQL server and MySQL to Access.

You can refer this direct link for referance:

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

If you want to do it programatically,

Step By Step Approach:

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

Sign up to request clarification or add additional context in comments.

1 Comment

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 CN.Close End If
0

You have used the same sub item id. Drop the inner for loop, e.g.:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.