Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Copy Data From One Table to other Table


Reply
 
Thread Tools Display Modes
  #1  
Old 01-18-2009, 08:07 AM
gloringg gloringg is offline
Newcomer
 
Join Date: Jan 2009
Posts: 11
Default Copy Data From One Table to other Table


Hi,

Currently using VB 2008 with MS Access 2003.

I have Two Tables with Names - " Company_Data" & "User_Data" in which i have the following columns.....

Company_Data

Name|Age|Department|Salary

User_Data

Name|Age|Department|Updated On

Now, Is there any code that can do the following:

when i select a name in the combo box on the form (The list in the combo box is from the Name in the Company_Data table) and click update.

It should copy the Details of the Record from Company_Data to User_Data with the current date in "Updated on" column.

Please Note that the columns are not exactly Same. (Salary is not necessary in the User_Data)


Thanks for your help.
Reply With Quote
  #2  
Old 01-18-2009, 07:57 PM
torpkevuk's Avatar
torpkevuk torpkevuk is offline
Contributor
 
Join Date: Oct 2003
Location: Nebraska, USA
Posts: 640
Default

It should copy the Details of the Record from Company_Data to User_Data with the current date in "Updated on" column.


do it using sql

insert into user_data
(field1, field2, field3)
SELECT field2, field3, field1, '1/18/2009'
FROM company_date
WHERE id = 'someid'
Reply With Quote
  #3  
Old 01-18-2009, 08:13 PM
Roger_Wgnr's Avatar
Roger_Wgnr Roger_Wgnr is offline
CodeASaurus Hex

Forum Leader
* Expert *
 
Join Date: Jul 2006
Location: San Antonio TX
Posts: 2,427
Default

To start with having the same data in two tables shows poor database design.
Check out the links on data base design
Data Design
Just how normal ARE you ?
__________________
Code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. ~Martin Golding
The user is a peripheral that types when you issue a read request. ~Peter Williams
MSDN Visual Basic .NET General FAQ
Reply With Quote
  #4  
Old 01-19-2009, 09:23 PM
torpkevuk's Avatar
torpkevuk torpkevuk is offline
Contributor
 
Join Date: Oct 2003
Location: Nebraska, USA
Posts: 640
Default

i agree, it shows poor database design.. HOWEVER.. we dont always have the luxury of altering how an application works or was designed.. i know *I* have had to build a lot of applications around 3rd party software, or built on systems designed by my predecessors

So if you have total control, time and the willpower, redesign your database so you're not replicating data.. if not, then try my solution
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->