Click here to Skip to main content
14,691,895 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 13:41pm
v2

Hi,

try the following....


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

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




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

dtfinal=Project_Group_qf_or_qg.Copy()
   
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
   
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month



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