Copy Data From One Table to other Table

gloringg

Member
Joined
Jan 11, 2009
Messages
16
Programming Experience
Beginner
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.
 
VB.NET:
Dim companyRow As DataRow = DirectCast(companyComboBox.Selecteditem, DataRowView).Row
Dim userRow As DataRow = userTable.NewRow()
Dim items As Object() = companyRow.ItemArray

items(3) = Date.Today 'Use Date.Now for time as well.
userRow.ItemArray = items
userTable.Rows.Add(userRow)
 
Please Correct This....Gives me an error when i run this as - Syntax error

cmd = New OleDbCommand("INSERT INTO [Company Data]([Company Name], [Emp Name],[EMp COde],[Age],[Salary],[Date of joining],[Comments])SELECT [User Data](Company Name], [Emp Name],[EMp COde],[Age],[Salary],[Date of joining],[Comments]) where [Employee Name] ='" & ComboBox1.Text & "')", con)
'Try
'cmd.Connection.Open()
'cmd.ExecuteNonQuery()
'Catch myException As Exception
'MsgBox("Couldn't insert record: " + myException.ToString())
'Finally
'cmd.Connection.Close()
'End Try

Here Company Data and User Data are 2 different Tables.
 

Latest posts

Back
Top