Results 1 to 12 of 12
  1. #1
    Join Date
    Oct 2003
    Posts
    7

    Unhappy Unanswered: Visual Basic and Access

    Hi!!!

    I only want to know if I could copy a table, from an Access Database, to another Access database, in a Visual Basic Programm

    If its posible, how can I do it, with a DAO connection?

    Thanks a lot , ;-P

    Marta

  2. #2
    Join Date
    Jan 2003
    Location
    New York
    Posts
    160
    Does the Second Database File(destination) already Exist??

    Does the Second table(destination) already exist??
    or are you updating an existing table??

    Are you limited to DAO ?
    Beyond Limitation

  3. #3
    Join Date
    Oct 2003
    Posts
    7
    Hi!

    The destination database exists.

    I want to compare a table from a first database, with a second table of a second database. I compare the fields of the first table with the fields of the second table. If they`ve the same fields, I want to drop the second table of the second database , and copy the first table of the first database, on the second database.

    Perhaps I haven`t explain it very correctly ;-P

    Marta.

  4. #4
    Join Date
    Oct 2003
    Location
    Sweden
    Posts
    45

    Copy tables between Access DBs

    Sounds like you only want to copy the contents and not the table itself.

    If the destination table already exists with the correct fields I think the easiest way would be to simply delete all records and then insert records from the source table one by one.

    There might be a more efficient way, but limited to dao and access I don't know of it.

    Cheers,
    Robert

  5. #5
    Join Date
    Oct 2003
    Location
    USA
    Posts
    4

    Re: Visual Basic and Access

    Yes,
    we can copy a table from an Access Database.


    Originally posted by Marta
    Hi!!!

    I only want to know if I could copy a table, from an Access Database, to another Access database, in a Visual Basic Programm

    If its posible, how can I do it, with a DAO connection?

    Thanks a lot , ;-P

    Marta

  6. #6
    Join Date
    Oct 2003
    Posts
    7
    Hi!

    Ok, we can copy a table from a Database to another Database.
    How can I do it with an ADO Connection?

    Thanks,

    Marta.

  7. #7
    Join Date
    Oct 2003
    Location
    USA
    Posts
    4

    Database Table

    If you are using ADO you could open the database and then use
    the Fields
    collection of the Recordset object (open each table in turn as
    a Recordset
    object) to get data about each column - the Field objects in
    the Fields
    collection correspond to the columns in your tables and have
    properties
    which describe the datatype, name etc. - you could then create
    a new
    database and add the fields from the above loop. Have a look
    in MSDN for the
    Fields collection (ADO).

    For more details
    sriharic84@hotmail.com





    Originally posted by Marta
    Hi!

    Ok, we can copy a table from a Database to another Database.
    How can I do it with an ADO Connection?

    Thanks,

    Marta.

  8. #8
    Join Date
    Oct 2003
    Posts
    7

    Re: Database Table

    Ok, thank you.

    If I use Fields Collection, I can copy the table field by field, but I do it. Now I want to copy all the table with all the information inside.
    I want to do it faster...

    How can I do it?

    Thanks in advance, ;-P

    Marta.

  9. #9
    Join Date
    Jan 2003
    Location
    New York
    Posts
    160
    declare database connection
    open database connection
    declare recordset

    open recordset = "select * into CopyToDatabaseName.dbo.TableNameYouWantToCreate from CopyFromDatabaseName.dbo.TableNameYouWantToCopy"

    execute recordset
    close recordset
    set recordset = nothing
    close database connection
    set database connection = nothing
    Beyond Limitation

  10. #10
    Join Date
    Oct 2003
    Location
    Sweden
    Posts
    45
    That looks really nice, vextout!
    I didn't know Access allowed for that between databases.

    I found a function for copying complete databases using DAO if that could be interesting... Source and further description here

  11. #11
    Join Date
    Jan 2003
    Location
    New York
    Posts
    160
    My Fault i forgot it was access
    with access you can use the following


    if you are in the same direcotry you created it in use this:
    select * into db1.b from db2.a

    if you wish to specify the path use this:
    select * into c:\db1.c from c:\db2.a
    Beyond Limitation

  12. #12
    Join Date
    Dec 2003
    Location
    India
    Posts
    2
    The query seems so easy...

    Could this be done with differnt types of databases, say MySql and access...

    Actually my problem is I have to take certain tables from a My Sql Database and write it to a Access Database.... though I could do it record by record that would be very slow....

    Do you have suggestions Vextout??
    Last edited by gokuld; 12-11-03 at 09:54.

Posting Permissions

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