Copy OleDb table, with schema and data RRS feed

  • Question

  • I am using OleDbConnection to Access databases, in a VB 2010 Windows Form Application.

    Trying to figure out how to copy a table from one OleDb database and add it to another, complete with column properties, keys and indexes. The table data is not an issue here.

    I can successfully copy the table between databases using SELECT INTO, but changes I make to the table in the source database dont come thru. 

    Thursday, March 24, 2016 10:13 PM


  • Dim cnLocal As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Docs\dbFrom.mdb;")
    Dim cmd As New System.Data.OleDb.OleDbCommand("SELECT * INTO [;DATABASE=C:\Docs\DBTo.mdb;].[Header] FROM Header WHERE ID = 2", cnLocal)

    The code above seems to work.  You have to drop the target table first.

    Found the code here:


    Friday, March 25, 2016 1:11 AM