473,320 Members | 1,859 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,320 software developers and data experts.

Copying a datarow

I am sure this must be REALLY simple, but I've spent the last 2 hours trying
to failing to figure out how to copy a datarow from an existing table to a
new table WITHOUT getting the following error:

Run-time exception thrown : System.ArgumentException - This row already
belongs to another table.

I know the row I want to copy and so my code looks like this:

Dim myTable As New DataTable
Dim myDataRow As Data.DataRow = dsProjectsGroup.Tables("Projects").Rows(i)
myTable.Rows.Add(myDataRow)

any ideas what I am doing wrong?
Jul 21 '05 #1
1 1371
I knew it had to be easy:

myTable.importrow(dsProjectsGroup.Tables("Projects ").Rows(i))
"Supa Hoopsa" wrote:
I am sure this must be REALLY simple, but I've spent the last 2 hours trying
to failing to figure out how to copy a datarow from an existing table to a
new table WITHOUT getting the following error:

Run-time exception thrown : System.ArgumentException - This row already
belongs to another table.

I know the row I want to copy and so my code looks like this:

Dim myTable As New DataTable
Dim myDataRow As Data.DataRow = dsProjectsGroup.Tables("Projects").Rows(i)
myTable.Rows.Add(myDataRow)

any ideas what I am doing wrong?

Jul 21 '05 #2

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

Similar topics

5
by: Nathan Sokalski | last post by:
I am writing an ASP.NET application in which I need to copy DataRows from one DataTable to another. When I use code such as the following: temprows = nodes.Select("state='PA'")...
1
by: Supa Hoopsa | last post by:
I am sure this must be REALLY simple, but I've spent the last 2 hours trying to failing to figure out how to copy a datarow from an existing table to a new table WITHOUT getting the following...
1
by: Mike9900 | last post by:
What is the best way to copy DataRow from one table to another table, without copying its structure, which means copying only its data. -- Mike
5
by: bh | last post by:
Ladies and Gentlemen, I need to transfer some data from Access accross to a table in SQL. I would use DTS except Im am using the Express version of SQL. I have set up 2 datasets in visual...
6
by: G .Net | last post by:
Hi I'm wondering if anybody can help me with the following problem? I have a table with several rows. I want to create a new table, with exactly the same structure, but has only a subset of...
1
by: byrd48 | last post by:
Hi, am attempting to create a DataTable by copying a table from a data set, then filter the rows as follows: DataTable dt = DataSet1.Tables.Copy; DataRow dr = dt.Select("myexpression"); ...
7
by: Wayne Gibson | last post by:
Hi All, Was wondering if anybody could help. I'm currently trying to copy a record from datatable to another. I have two problems: 1) Transferring the record from one datatable to another. 2)...
0
by: MathewJose | last post by:
Hi, I have a DatagridView in windows form.It has got a column which has some names that are populated from master table in database.Now i need to copy a set of data against these names. I...
1
by: tshad | last post by:
Running on VS.net 2005, I am trying to copy rows from my datatable to another datatable in the same dataset. The schema would be identical. I need to make the table name "forms" as I am...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.