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 2 1733
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 dataview to datatable).
The dataview is being filtered. However when I assign it
to the datatable it is not filtered. I put some debug
code in and the Dataview has 8 records then I assign it to
a new datatable. When I check the row count of the...
|
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 21 12 32
2 1 43 12
3 32 12 35
I need to output:
|
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 DataTable LoadStuff()
{
DataTable dt = new DataTable();
....
dt.Columns.Add(...)
....
|
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, but my
copy of the row will be preserved?
If I try to do something like this:
this.oleDbWbuserAdapter.SelectCommand.CommandText =
"SELECT * FROM wbuser where username='bennett';";
this.oleDbWbuserAdapter.Fill(ds1.wbuser);
|
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
changes in dta, dta2 is also changed...
For example:
| |
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 would contain the seconf
1/2 of the original DataTable.
I am aware of the .Copy method of the DataTable but was hoping that
someone would know of an easy way to just copy the top 50% and bottom
50% of a DataTable.
|
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();
Cache.Insert("CacheTable", ToBeInserted);
public DataTable function()
{
DataTable Results = (DataTable)Cache;
Results.Columns.Add("Rank");
return Results;
|
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 Integer = start To last
table1.Rows.Add(table2.Rows(i))
Next
However, the code above gives an error saying the DataRow is already used in
another DataTable. Is there any easy way to copy a DataRow from one
|
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 DataRow
Dim rowSet As DataRow()
rowSet = dtUn.Select("Distinct Member_id is not null")
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |