Best way to copy Data from one DataTable to another DataTable with diffrent structure?

I'm not 100% sure why you want to copy the data to an array before putting it into the VendorInvoiceTable, but either way: IEnumerable query = from vendInv in VendorInvoiceStagingTable.AsEnumerable() where vendInv. Field(VendInvoice. Number) == InvoiceHeader select vendInv; // Would this be ok?

VendorInvoiceTable.Rows. Add(query.First(). ItemArray); // ...or if not, how about this?

Object sourceData = query.First(). ItemArray; object targetData = new objectsourceData. Length; sourceData.

CopyTo(targetData, 0); VendorInvoiceTable.Rows. Add(targetData).

Add method takes array of objects – Gainster Apr 23 at 12:15 DataRow. ItemArray is an object, and so is targetData... am I missing something? – Steve Wilkes Apr 23 at 12:20 Since source contains less columns then the target.

I will get expection. – Gainster Apr 23 at 12:28 Oh, ok - so you only want to select and copy a subset of the columns from vendInv? You could do that by selecting an anonymous type instead of the whole object, so instead of select vendInv; ...you use: select new { vendInv.

Column1, vendInv. Column2, vendInv. ColumnN }; – Steve Wilkes Apr 23 at 12:41 targetData has length 10 in my case while source have 30 elements , so options will not work.

– Gainster Apr 23 at 12:42.

Probably, check out Adapter pattern, it will allow you to adapt the structure of one data table to another. A simple explanation and sample code can be found at Dofactory.

To another server database table in oracle. Pease help me. I have imported text file file into SQl db, I wan to change the impoted tbale to exixting table.

How can I export data from one table to another table in different database using SQL query. Today this query is done in 10 hours, which is highly unacceptable, how can I solve this? I’m thinking about devide-n-conquer where each record given an identity, and insert records in 10.000 records/iteration?

I have to copy 2 colums,which are from 2 different tables, in to another table . When I am trying insert into,it is giving error. An object or column name is missing or empty.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions