Results 1 to 8 of 8

Thread: Adding a Recordset to a Table??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163

    Question Adding a Recordset to a Table??

    Hi guys
    Well I have two tables in two distinct dbs(of course the tables’ stracture are the same. I mean the same fields &…). And I want to move some records of one to another. The simplest and the slowest way to this is to:
    1.read on record form A
    2.add the record to B
    3.remove the record from A
    and do it for each record to the end. But it is toooooo slow. I’m looking for a way that I can create a recordset of records I want to move. And just add the recordset to the table but I don’t know how to do this. I mean adding a recordset to a table.
    Can anybody help or give me some other solution to this?
    thanks alot

  2. #2
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    Sure: What database are you using?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163
    Originally posted by Gaffer
    Sure: What database are you using?
    I'm using an access db and DAO for codeing

  4. #4
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    You only need to use SQL.

    1. Create a query, based on the following SQL:

    INSERT INTO myTargetTable
    SELECT * FROM mySourceTable IN 'c:\SourceDB.mdb';

    2. Remove the records from your source table
    DELETE * FROM mySourceTable IN 'c:\SourceDB.mdb';

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163
    Originally posted by Gaffer
    You only need to use SQL.

    1. Create a query, based on the following SQL:

    INSERT INTO myTargetTable
    SELECT * FROM mySourceTable IN 'c:\SourceDB.mdb';

    2. Remove the records from your source table
    DELETE * FROM mySourceTable IN 'c:\SourceDB.mdb';
    I don't see any TargetTable in these SQL statement. can u give me a simple code? I write the first part & u do the other

    dim db1 as DAO.DataBase
    dim db2 as DAO.DataBase

    Set db1 = DBEngine.OpenDatabase("c:\source.mdb")
    Set db2 = DBEngine.OpenDatabase("c:\target.mdb")

    ok now what sould i do? open tables whit those SQL statements?

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. db2.execute "INSERT INTO myTargetTable
    2. SELECT * FROM mySourceTable IN 'c:\SourceDB.mdb'"
    3.  
    4. db2.execute "DELETE * FROM mySourceTable IN 'c:\SourceDB.mdb'"
    -= a peet post =-

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163

    Thumbs up

    thanks alot i got it

  8. #8
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225
    hi guys ... i also got same kind of problem , i want to just copy some records from one recordset to a access table . but prob is a bit different in way that i have tow databse . the source database is Oracle from which i made one recordset . and this recordset i want to add in my access table . Here we gave Insert in to table name and select query . but how i can do it if my source database or table is in oracle and destination table is in Access .

    any clues ..
    Chander
    Email:[email protected]

Posting Permissions

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



Click Here to Expand Forum to Full Width