Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
| Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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 April 17th, 2005, 08:37 AM
Authorized User
 
Join Date: Mar 2005
Location: delhi, Delhi, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to akash Send a message via MSN to akash
Default UpDATE IN VB FROM TWO DATABASES

I want to update one table from another table in another database. U can say table A is in Database DBA and table B in Database DBB , I have to update records in table A from table B using UPDATE SQL command.

Help me please

 
Old April 18th, 2005, 04:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Which type of database? Access? SQL Server? Something else?
 
Old April 18th, 2005, 05:29 AM
Authorized User
 
Join Date: Mar 2005
Location: delhi, Delhi, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to akash Send a message via MSN to akash
Default

Sorry It is Access database

 
Old April 18th, 2005, 05:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

OK, Access has IN keyword so you can specify another database. For example, from Database which contains Table A use SQL like this:
INSERT INTO TableA
SELECT <<fields>> FROM TableB IN "<<path of other mdb file>>" WHERE ...

hth
Phil
 
Old April 19th, 2005, 03:17 AM
Authorized User
 
Join Date: Mar 2005
Location: delhi, Delhi, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to akash Send a message via MSN to akash
Default

Thx Phil for the solution but I want to update the existing table A. The above INSERT command adds fresh records in tableA from table B. Is there any solution with update command please let me know.

Thx
Akash


 
Old April 20th, 2005, 03:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

You will need a subquery for this, something like:
UPDATE TableA
SET TableA.FieldName =
(SELECT OtherField FROM TableB IN "<<path of other mdb file>>" WHERE TableA.linkField = TableB.LinkField)

hth
Phil




Similar Threads
Thread Thread Starter Forum Replies Last Post
VB Databases brawny4 VB Databases Basics 1 March 14th, 2007 08:41 AM
vb and databases , is it possible.... Blue Eyes Visual Basic 2005 Basics 3 July 19th, 2006 05:04 PM
VB databases and Reports samnikh VB Databases Basics 1 July 4th, 2005 12:32 AM
Update two databases at the same time Arsi SQL Server 2000 10 November 18th, 2004 06:38 PM
Access Databases won't update through code wwwaynes Access ASP 2 October 3rd, 2004 03:33 PM





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