none
C# How can I copy a whole table from MS Access database to another? RRS feed

  • Question

  • Hello

    I Found the Solution in VB Format, my Question is how can we transfer Data from One Table of Database1 of Ms Access to Another Database of Table2 Ms Access

    Saturday, August 25, 2018 1:27 PM

All replies

  • Hi,

    If you want to transfer data via Vb.net, the following code for your reference.

    Sub Main()
            Dim myConnectionString As String
            myConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=D:\Data\Access\Test.accdb;"
            Using con As New OleDbConnection(myConnectionString)
                con.Open()
                Using cmd As New OleDbCommand()
                    cmd.Connection = con
                    cmd.CommandType = CommandType.Text
                    cmd.CommandText = "INSERT INTO Table2 IN 'D:\Data\Access\\Test2.accdb' " & "SELECT * FROM OPERATELOGTITLE WHERE ID < 103"
                    cmd.ExecuteNonQuery()
                End Using
                con.Close()
            End Using
            Console.WriteLine("Done.")
        End Sub

    You could copy the table from database1 and paste in another database and select "Structure and Data", and you could change the table name as you want.

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 27, 2018 2:01 AM
    Moderator