Results 1 to 13 of 13

Thread: copy table from a database to annother[RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Resolved copy table from a database to annother[RESOLVED]

    Hi:

    I need to copy a table(india) in a database(new.mdb) to annother database(news.mdb).

    Any help please?

    Thanks
    Last edited by sacramento; Jul 13th, 2005 at 01:24 PM.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: copy table from a database to annother

    It might look something like this...
    VB Code:
    1. INSERT INTO india [IN news.mdb] SELECT india.* FROM india
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: copy table from a database to annother

    This maybe work,but if I have these 2 databases in a diferents paths?

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: copy table from a database to annother

    You just have to set their path.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: copy table from a database to annother

    yes ok...I have to set their path,but I'm a litlle confused here because I have two databases and I just have one instruction...wich database I must set?

    Can you post a little piece of code to show your point of view?

    Thanks

  6. #6
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: copy table from a database to annother

    Provide me the path's of those two database then perhaps I could code it for you.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: copy table from a database to annother

    hi:

    The paths are:

    source path - c:\program files\exp\new.mdb

    destination Path - c:\program files\dali\news.mdb

    Table with all records to copy from the source path - india

    table for destination path - india


    note:The databases are equals...they have the same tables,everything is equal...the diference is the path!

    Thanks

  8. #8
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: copy table from a database to annother

    Try this...

    VB Code:
    1. 'reference microsoft ActiveX Data Objects
    2. Dim adoConnection As ADODB.Connection
    3. Set adoConnection = New ADODB.Connection
    4. adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\program files\exp\new.mdb"
    5. adoConnection.Execute "INSERT INTO india [IN 'c:\program files\dali\news.mdb'] SELECT india.* FROM india"
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: copy table from a database to annother

    hi:

    thanks for your reply!

    I have convert the code for my reality and I got this error:

    Run time error '3134'
    Syntax error in INSERT INTO statement

    Code:
    Dim db As Database
    Set db = Workspaces(0).OpenDatabase("c:\program files\exp\new.mdb")
    db.Execute "INSERT INTO india [IN 'c:\program files\dali\news.mdb'] SELECT india.* FROM india"
    3

    Thanks

  10. #10
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: copy table from a database to annother

    This should work...

    VB Code:
    1. Dim db As Database
    2. Set db = Workspaces(0).OpenDatabase("c:\program files\exp\new.mdb")
    3. db.Execute "INSERT INTO india IN 'c:\program files\dali\news.mdb' SELECT india.* FROM india"
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: copy table from a database to annother

    thanks for your help...now the code work very well

  12. #12
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: copy table from a database to annother[RESOLVED]

    Glad it worked now!
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  13. #13
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: copy table from a database to annother

    Quote Originally Posted by dee-u
    This should work...

    VB Code:
    1. Dim db As Database
    2. Set db = Workspaces(0).OpenDatabase("c:\program files\exp\new.mdb")
    3. db.Execute "INSERT INTO india IN 'c:\program files\dali\news.mdb' SELECT india.* FROM india"
    Dee-u do you have any idea what the syntax would be when both databases are password protected?
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

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