Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003

    Unanswered: How to open multiple MDB in VB6

    Im trying to read 3 Access MDB files then merge it into 1 MDB. Im actually consolidating all tables of 3 MDB into 1 MDB database file.

    Is there anyone tried these before using VB6?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2004

    Re: How to open multiple MDB in VB6

    Once you have your initial recordset, create a new connection to the second database, from there call your SQL statements using the new connection Do the same thing for the third database. Here is an example with 2 databases:

    Dim Connection1 as ADODB.Connection
    Dim Connection2 as ADODB.Connection
    Dim rs as ADODB.Recordset

    Set Connection1 = new ADODB.Connection
    Set Connection2 = new ADODB.Connection

    Connection1 .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\Test1.mdb;Persist Security Info=False"


    rs.Open "SELECT * FROM Table1", Connection1

    Connection2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\Test2.mdb;Persist Security Info=False"


    Connection2.Execute "INSERT Table2(Field1) SELECT '" & rs.Fields("Field1") & "'"



    Set rs=Nothing
    Set Connection1= Nothing
    Set Connection2= Nothing

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts