HighTechTalks DotNet Forums  

copying the column values of a Datatable into another data table in vb.net

Dotnet FAQs microsoft.public.dotnet.faqs


Discuss copying the column values of a Datatable into another data table in vb.net in the Dotnet FAQs forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Balu
 
Posts: n/a

Default copying the column values of a Datatable into another data table in vb.net - 01-02-2006 , 06:14 AM






Hi All,

Can anybody tell me how to copy one column of a data table to another data
table.

Example:I have 2 data tables say dt1,dt2.
Here,i wanna copy only the 1st column values of dt1 into the 1st column of
dt2.
Its an urgent work for me.So,anyone of you can give me a solution to this.

Regards,
Mahalakshmi.



Reply With Quote
  #2  
Old   
Cindy Winegarden
 
Posts: n/a

Default Re: copying the column values of a Datatable into another data table in vb.net - 01-02-2006 , 09:00 AM






Hi Mahalakshmi,

Does the Copy() method that Christopher Reed suggested in your other thread
work for you?

Quote:
tblTwo = tblOne.Copy();
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden (AT) msn (DOT) com www.cindywinegarden.com


"Balu" <balu (AT) nannacomputers (DOT) com> wrote

Quote:
Hi All,

Can anybody tell me how to copy one column of a data table to another data
table.

Example:I have 2 data tables say dt1,dt2.
Here,i wanna copy only the 1st column values of dt1 into the 1st column of
dt2.
Its an urgent work for me.So,anyone of you can give me a solution to this.

Regards,
Mahalakshmi.




Reply With Quote
  #3  
Old   
Balu
 
Posts: n/a

Default Re: copying the column values of a Datatable into another data table in vb.net - 01-02-2006 , 11:17 PM



Hi,
Its working fine.But,i wanna copy only one column of a table not the
entire data.
But,the statement .....
tblTwo=tblOne.Copy()
copies the entire data,i.e.,all column values into another table.
Can anybody give a solution for it?

Regards,
Maha.
"Cindy Winegarden" <cindy_winegarden (AT) msn (DOT) com> wrote

Quote:
Hi Mahalakshmi,

Does the Copy() method that Christopher Reed suggested in your other
thread work for you?

tblTwo = tblOne.Copy();

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden (AT) msn (DOT) com www.cindywinegarden.com


"Balu" <balu (AT) nannacomputers (DOT) com> wrote in message
news:OuE1%2324DGHA.740 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
Hi All,

Can anybody tell me how to copy one column of a data table to another
data table.

Example:I have 2 data tables say dt1,dt2.
Here,i wanna copy only the 1st column values of dt1 into the 1st column
of dt2.
Its an urgent work for me.So,anyone of you can give me a solution to
this.

Regards,
Mahalakshmi.






Reply With Quote
  #4  
Old   
Cindy Winegarden
 
Posts: n/a

Default Re: copying the column values of a Datatable into another data table in vb.net - 01-03-2006 , 07:47 PM



Hi Balu,

Are you saying that you want to add a new column to a table and populate it
or populate a column that's already there but is empty? To do that you'll
need to use an update statement and connect the record in the source table
to the record in the target table via a primary key. It's not as easy as
copying/pasting a column in Excel, for example.

In a SQL Server script this would be something like:

Alter Table Target Add NewColumn Integer
Go
Update Target
Set Target.NewColumn =
(Select Source.OldColumn From Source
Where Source.PrimaryKey = Target.PrimaryKey)

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden (AT) msn (DOT) com www.cindywinegarden.com


"Balu" <balu (AT) nannacomputers (DOT) com> wrote

Quote:
Hi,
Its working fine.But,i wanna copy only one column of a table not the
entire data.
But,the statement .....
tblTwo=tblOne.Copy()
copies the entire data,i.e.,all column values into another table.
Can anybody give a solution for it?

Regards,
Maha.
"Cindy Winegarden" <cindy_winegarden (AT) msn (DOT) com> wrote in message
news:Ovl72T6DGHA.208 (AT) tk2msftngp13 (DOT) phx.gbl...
Hi Mahalakshmi,

Does the Copy() method that Christopher Reed suggested in your other
thread work for you?

tblTwo = tblOne.Copy();

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden (AT) msn (DOT) com www.cindywinegarden.com


"Balu" <balu (AT) nannacomputers (DOT) com> wrote in message
news:OuE1%2324DGHA.740 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
Hi All,

Can anybody tell me how to copy one column of a data table to another
data table.

Example:I have 2 data tables say dt1,dt2.
Here,i wanna copy only the 1st column values of dt1 into the 1st column
of dt2.
Its an urgent work for me.So,anyone of you can give me a solution to
this.

Regards,
Mahalakshmi.








Reply With Quote
  #5  
Old   
Balu
 
Posts: n/a

Default Copying data of one data table to another data table. - 01-06-2006 , 02:26 AM



Hi Cindy,
Thanks for ur reply.
But,actually what i want is, to copy a single column of the data table say
'dt1' to a column in another data table say 'dt2'.
I am using dt2=dt1.
But,its copying the entire data of data table 'dt1' to data table 'dt2'.
What i want is to copy only the 1st column data of dt1 to 1st column of dt2.
If you have any idea?Please do reply....waiting for ur reply.

Regards,
Maha.
"Cindy Winegarden" <cindy_winegarden (AT) msn (DOT) com> wrote

Quote:
Hi Balu,

Are you saying that you want to add a new column to a table and populate
it or populate a column that's already there but is empty? To do that
you'll need to use an update statement and connect the record in the
source table to the record in the target table via a primary key. It's not
as easy as copying/pasting a column in Excel, for example.

In a SQL Server script this would be something like:

Alter Table Target Add NewColumn Integer
Go
Update Target
Set Target.NewColumn =
(Select Source.OldColumn From Source
Where Source.PrimaryKey = Target.PrimaryKey)

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden (AT) msn (DOT) com www.cindywinegarden.com


"Balu" <balu (AT) nannacomputers (DOT) com> wrote in message
news:eYXluyBEGHA.1676 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
Hi,
Its working fine.But,i wanna copy only one column of a table not the
entire data.
But,the statement .....
tblTwo=tblOne.Copy()
copies the entire data,i.e.,all column values into another table.
Can anybody give a solution for it?

Regards,
Maha.
"Cindy Winegarden" <cindy_winegarden (AT) msn (DOT) com> wrote in message
news:Ovl72T6DGHA.208 (AT) tk2msftngp13 (DOT) phx.gbl...
Hi Mahalakshmi,

Does the Copy() method that Christopher Reed suggested in your other
thread work for you?

tblTwo = tblOne.Copy();

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden (AT) msn (DOT) com www.cindywinegarden.com


"Balu" <balu (AT) nannacomputers (DOT) com> wrote in message
news:OuE1%2324DGHA.740 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
Hi All,

Can anybody tell me how to copy one column of a data table to another
data table.

Example:I have 2 data tables say dt1,dt2.
Here,i wanna copy only the 1st column values of dt1 into the 1st column
of dt2.
Its an urgent work for me.So,anyone of you can give me a solution to
this.

Regards,
Mahalakshmi.










Reply With Quote
  #6  
Old   
Cindy Winegarden
 
Posts: n/a

Default Re: Copying data of one data table to another data table. - 01-06-2006 , 10:21 AM



As I posted above, that's exactly what the code I posted above does.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden (AT) msn (DOT) com www.cindywinegarden.com


"Balu" <balu (AT) nannacomputers (DOT) com> wrote

Quote:
... copy a single column of the data table say 'dt1' to a column in
another data table say 'dt2'.



Reply With Quote
Reply




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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.