Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 21st, 2005, 01:30 AM
Friend of Wrox
Join Date: Jun 2003
Location: Norwich, Norfolk, United Kingdom.
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copying from one table to another

I have DAO connections to two databases dbNew and dbOld. I want to copy data from a table in dbOld to a table in dbNew. Currently I have done it by creating two recordsets and looping through them.

I wonder if it would be more efficient to use the INSERT INTO statement? But I cannot get it to work. I can do it from table to a table in the same database but not from a table in one database to a table in another database. Can anybody give me a clue how to start please.

Many thanks.

Clive Astley
Clive Astley
Reply With Quote
  #2 (permalink)  
Old August 22nd, 2005, 10:46 AM
Authorized User
Join Date: May 2005
Location: Berlin, CT, USA.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts

Typically, when you want to reference tables in dbnew from dbold or vice versa, you must "link" the databases. For example, Oracle provides functionality to LINK two databases as follows: Let's assume we want to link dbNew to dbOld...

Assuming we are logged onto dbOld...

  CONNECT TO username IDENTIFIED BY password
  USING dbNew

(This assumes that dbNew is the name the database is known by.)

Once this link has been established, then all tables/views/data of dbNew are now available in dbOld, and you reference them as such:

SELECT fieldname FROM tablename@linkname;

the "@" followed by linkname that you provide tells the database that you want to access the linked database.

Once you establish this sort of linking, you can then easily implement inserts from one table to another via SQL.

Other database engines apply similar principles.

Reply With Quote
  #3 (permalink)  
Old August 23rd, 2005, 12:48 AM
Friend of Wrox
Join Date: Jun 2003
Location: Norwich, Norfolk, United Kingdom.
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts

Many thanks Cliff.

Clive Astley
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
copying values into a column from another table madrob3975 SQL Server 2000 1 December 8th, 2006 03:31 AM
Copying Table From one Database To Anoter Database jayanth_nadig VB Databases Basics 1 June 19th, 2006 02:39 PM
copying from table 1 inserting in table 2 gilgalbiblewheel Java GUI 0 September 15th, 2004 03:40 PM
Copying Table Relationship Diagram mike123abc SQL Server 2000 1 February 19th, 2004 09:16 AM
copying array to table (reverse of getrows?) rachelow VB Databases Basics 0 July 19th, 2003 03:10 AM

All times are GMT -4. The time now is 04:06 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.