473,836 Members | 2,358 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

adding rows from one datatable to another

Sam
Hi,
The following code :
For Each r As DataRow In dtFlow.Rows
Dim arow As DataRow = dtAllFlows.NewR ow
arow = r
dtAllFlows.Rows .Add(arow)
Next

leads to the error 'This row already belongs to another table '
at the line dtAllFlows.Rows .Add(arow).
I guess I should just do dtAllFlows = dtFlow.copy, but I can't as the
code above is contained in a For loop and at each iteration, I add new
rows (dtFlow changes at each iteration).

How can I solve this problem ?

Regards

Nov 21 '05
21 22732
Sam,
NOOOOOOOOOOOO !!!!!!! :-) I think we'll never understand each other on
this one, LOL
I don't want to add a table to two datasets. I just want to :


I know however what I showed you is the same as

\\\
dim dt as datatable = dtold.clone
for each row as datarow in dtold
dt.importrow(ro w)
next
///

However mayby you want to do it selective than you need this one.

:-)

Cor
Nov 21 '05 #21
hi guys..

Pls be careful when using the below options if your appln architecture is
using rowstates
1) importrow does not modify the rowstate as added.

2) methods like remove() are not advisable if what you want to do is just
delete it is like calling delete and acceptchanges.

3) i too did not understand this one..

Tnx

"Cor Ligthert" wrote:
Sam,

Quickly writen in this messages so watch typos or others.

The first
\\\
dim dtnew as datatable = dtOld.Clone
dtnew.rows.Add( dt.newrow)
dtnew.importrow (dtOld.Rows(0))
///
The second
\\\
dim dtnew as datatable = dtOld.Clone
dtnew.rows.Add( dt.newrow)
dim dr as datarow = dtnew.rows(0)
dt.rows.remove( 0)
dtnew.rows.Add( dr)
///
The third
\\\
dim dv = new dataview(dtOld)
'in a dv the show on a datarow is to get (as I showed you before) as a
datarowview
///

I hope this give some ideas

Cor

Nov 21 '05 #22

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

Similar topics

2
3643
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete a row. Everything works just fine. BUT I would like to add a button to (for example) the DataGrid header, which when pressed will add a new row to the datagrid. This should then allow the user to enter information into text boxes (in some...
3
8288
by: Arek | last post by:
I need to have a simple table. User and application will add rows to it. I've used DataGrid but I can't add rows by application. I've got such code: DataRow row = dataTable.NewRow(); row.BeginEdit(); row.ItemArray.SetValue("0", 0); row.ItemArray.SetValue("0", 1); row.ItemArray.SetValue("0", 2); row.ItemArray.SetValue("0", 3); row.EndEdit(); dataRow.ImportRow(row);
1
1871
by: J. Babe | last post by:
I was wondering how to add the first 20 rows from one datatable to another datatable without getting the error: This row already belongs to another table
3
4889
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
1
3301
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple days of struggling, I figure asking you all (the experts) will keep me from going down some dark and dangerous road. The project I have is a fairly simple one, in theory anyway. The gist is to create a page where the user enters an IDNumber,...
0
2410
by: Luis Esteban Valencia | last post by:
Hello I wrote a program with code behind in C# to add row into table dynamically and the program worked very well in .Net Framework 1.1. When I run this program in .Net Framework 2.0 beta version, the program is not working as in version 1.1. So what is the problem? Microsoft declared that the version 2.0 is fully backward support, but it is not. Is that the problem with 2.0 version? I find out the problem in version 2.0. After...
7
1676
by: EricJ | last post by:
Hi all im a bit confused here, I m trying to add the rows from 1 dataset.tables(0).rows to another ds2.tables(0).rows.add(row) there is probably a better way to do this than going looping true the rows (if you know tell me ;p), but that is how im trying to do this atm. at a certain point i get an error message : This row already belongs to another table. i dont know w i am doing wrong (not that it is nice code but i added it below...
4
8752
by: VMI | last post by:
I'm working on a questionaire, and I'd like to add the questions to a gridview, so that each row (of two "columns" each) has the question in one field, and the editable section (where the user will enter the answer) in the next field. The questions are not stored in a table, and I'm thinking of saving the answers manually (i.e. no datasource). Is this possible? This is a web app using asp.net 2.0. THanks.
6
2358
by: Paulers | last post by:
Hello, I have a string that I am trying to add each char to a datatable row. for example if I have a string that looks like "abcdefg", I would like to break it up into an array of characters so I can do this: myDataTable.Rows.Add(array()) instead of myDataTable.Rows.Add("a","b","c","d","e","f","g")
0
1970
by: ganesh22 | last post by:
Hi... Iam using GridView in asp.net(2.0) .My requirement is user can add,update,delete in gridview I written the code for add & update but can u help adding rows in grid view My code: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3" Height="237px" Style="z-index: 100; left: 155px; position: absolute; top: 132px" Width="688px" BackColor="White" BorderColor="#CCCCCC"...
0
9810
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9656
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,...
0
10821
Oralloy
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...
1
10573
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,...
0
10241
tracyyun
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...
0
9358
agi2029
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...
1
7773
isladogs
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...
0
5812
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4443
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.