Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 21st, 2005, 01:30 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old August 22nd, 2005, 10:46 AM
Authorized User
 
Join Date: May 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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...

CREATE DATABASE LINK linkname
  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.

 
Old August 23rd, 2005, 12:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Many thanks Cliff.

Clive Astley





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





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