Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using VS2008;
The problem is that i am not been able to import the rows from one datatable to another. Can you suggest any other safe way ? Quick answer will be highly appreciated.
Regards.
foreach (DataRow dc1 in Project_Group_qf_or_qg.Rows)
{
    dtfinal.ImportRow(dc1);
}
Posted
Updated 22-Dec-11 12:41pm
v2

Hi,

try the following....


C#
foreach (DataRow dc1 in Project_Group_qf_or_qg.Rows)
                {
                   dtfinal.Rows.Add(dc1);
                }.



or if you want to add a row at specified position

C#
foreach (DataRow dc1 in Project_Group_qf_or_qg.Rows)
                    {
                        dtfinal.dsEmployee.Tables[0].Rows.InsertAt(dc1,inserting position);
                    }.




Hope this helps
 
Share this answer
 
Comments
RaviRanjanKr 22-Dec-11 17:19pm    
5+
You Can Use

dtfinal=Project_Group_qf_or_qg.Copy()
 
Share this answer
 
foreach (DataRow dc1 in Project_Group_qf_or_qg.Rows)
                {
                   dtfinal.Rows.Add(dc1);
                   dtfinal.AcceptChanges();
                }


Once u added some values to the datarow,the data table should acept the changes....

try the above codes
 
Share this answer
 
v2
Comments
RaviRanjanKr 22-Dec-11 17:20pm    
[Edited]Code is wrapped in "pre" tag[/Edited]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900