473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Copy a Subset of Datatable

Hi,

I created a datatable (dt1) of 3 columns A, B, C, and I want to copy this
datatable into another datatable (dt2) but without the column B. How to do
this?

Thanks in advance
Nov 21 '05 #1
2 1712
Li Pang wrote:
Hi,

I created a datatable (dt1) of 3 columns A, B, C, and I want to copy this
datatable into another datatable (dt2) but without the column B. How to do
this?

Thanks in advance


For Each R as DataRow in dt1
Dim R2 as DataRow = Dt2.NewRow
R2(0) = R(0)
R2(1) = R(2)
R2(2) = R(3)
dt2.Rows.Add(r2)
Next

Out of curiousity, why do you want to do this? It seems that there are
probably better ways of doing what you need in the end than doubling the
data.

Chris
Nov 21 '05 #2
Thanks Chris,

R2(2) = R(3) should be excluded. I just want to bind them to different
controls.
"Chris" wrote:
Li Pang wrote:
Hi,

I created a datatable (dt1) of 3 columns A, B, C, and I want to copy this
datatable into another datatable (dt2) but without the column B. How to do
this?

Thanks in advance


For Each R as DataRow in dt1
Dim R2 as DataRow = Dt2.NewRow
R2(0) = R(0)
R2(1) = R(2)
R2(2) = R(3)
dt2.Rows.Add(r2)
Next

Out of curiousity, why do you want to do this? It seems that there are
probably better ways of doing what you need in the end than doubling the
data.

Chris

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dianna K. | last post by:
I have a dataview which I am assigning to a Datatable (I am doing this because currently Crystal Reports will not accept a dataview as a Reportsource -- The recommended work-around is to assign...
3
by: Matthew Wieder | last post by:
I have a datatable as a source and I need to produce a datatable which is all the rows in the original datatable except the first row, copied n times. So, if I had a datatable of: A B C...
1
by: bubby | last post by:
Should I be concerned about the classic "Deep/Shallow" copy problem when returning objects, specifically a DataTable or DataView from a method? For example, see the code below: private...
0
by: Bennett Haselton | last post by:
If I have just filled a DataTable in a typed DataSet with a single row, is there a way I can make a copy of that row, so that I can clear the DataTable in that DataSet and use it for another query,...
4
by: Férnas | last post by:
Hey guys, In my app, I have a DataTable named "dta"... If i create a new variable of DataTable type named "dta2", and assign the dta as value, it creates a reference to dta, then, when I make...
0
by: mikejacobz | last post by:
Hi, I have a Datatable which I would like to copy into two other DataTables. The first copy of the DataTable would contain the first 1/2 of the original DataTable whilst the second DataTable...
1
by: ceestand | last post by:
I am having a weird (to me at least) problem retrieving a copy of an item in the Cache. I do something like this: DataTable ToBeInserted = FunctionThatReturnsDataTable();...
9
by: Nathan Sokalski | last post by:
I have a DataTable from which I only need a certain range of the DataRows. What I would like to do is copy a range of rows from one DataTable to a new DataTable like the following: For i As...
1
by: SunshineInTheRain | last post by:
Dim dtUn As DataTable dtUn= New DataTable dtUn = BindICUN() Dim i As Integer Dim irow As DataRow Dim mailBody As String = "" Dim myRow As...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.