N
Nathan Sokalski
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'")
temptable.Clear()
For Each row As DataRow In temprows
temptable.Rows.Add(row)
Next
I recieve the following error:
[ArgumentException: This row already belongs to another table.]
System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32 pos)
+450
System.Data.DataRowCollection.Add(DataRow row) +14
WebApplication1.WebForm2.Page_Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\WebApplication1\WebForm2.aspx.vb:43
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +739
I could not find any method that is used for copying a DataRow (like the
DataTable class has a Copy() method). Is there any way to copy individual
DataRows without manually reading each property and creating a new DataRow?
Thanks.
one DataTable to another. When I use code such as the following:
temprows = nodes.Select("state='PA'")
temptable.Clear()
For Each row As DataRow In temprows
temptable.Rows.Add(row)
Next
I recieve the following error:
[ArgumentException: This row already belongs to another table.]
System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32 pos)
+450
System.Data.DataRowCollection.Add(DataRow row) +14
WebApplication1.WebForm2.Page_Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\WebApplication1\WebForm2.aspx.vb:43
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +739
I could not find any method that is used for copying a DataRow (like the
DataTable class has a Copy() method). Is there any way to copy individual
DataRows without manually reading each property and creating a new DataRow?
Thanks.