Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 03-02-2009
Member
 
Join Date: Jan 2009
Posts: 10
How to copy a datarow from one table to another?

Hi,
I want to copy datarow from one table & then insert into another table, but i am having some problems with this.

I don't know what is the correct way to do this? I tried the import row method but it gives an exception.

Thanks for the help.
Reply With Quote
  #2  
Old 03-02-2009
Member
 
Join Date: Jun 2008
Posts: 144
Re: How to copy a datarow from one table to another?

Hey you can do this by using the ItemArray property, and then attaching the new row to the destination table via InsertAt.

I hope this helps you!
Reply With Quote
  #3  
Old 03-02-2009
Member
 
Join Date: Jan 2009
Posts: 10
Re: How to copy a datarow from one table to another?

Thanks Ettan!
I tried using ItemArray property but it gives me an the datarow at the last record but not on the position where i want it to be shown.
What could be the problem?
Reply With Quote
  #4  
Old 03-02-2009
Member
 
Join Date: Jun 2008
Posts: 144
Re: How to copy a datarow from one table to another?

Hi,
Why don't you use dataview with properties set instead of datagrid?
I think this will solve your problem.
Reply With Quote
  #5  
Old 21-07-2009
Member
 
Join Date: Jul 2009
Posts: 1
Re: How to copy a datarow from one table to another?

HI, you can try the follow to copy a datarow to anothher table:

First, copy the schema of the table you want to copy, to the new table

dim newTable as new dataTable
newtable=originalTable.Clone

after that, using ImportRow you can copy the rows you want
For n As Integer = 0 To originalTable.Rows.Count - 1

newtable.ImportRow(originalTable.Rows(n))

Next

hope it helps you!! it's the best way
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to copy a datarow from one table to another?"
Thread Thread Starter Forum Replies Last Post
How to copy a pivot table into a 2 dimensional table ? Udyami Windows Software 4 27-11-2010 11:35 PM
SQL Query For Copy records from one table to another Bellamy Software Development 4 23-05-2010 12:36 AM
Copy field in same table Miles Runner Software Development 4 17-02-2010 02:13 AM
How to copy one table data into another table directly? ComPaCt Software Development 3 22-09-2009 03:54 PM
Is there any way i can copy a Word table into Excel Apple.Mac.Rocker Windows Software 3 29-08-2009 08:08 PM


All times are GMT +5.5. The time now is 11:16 PM.