I have two datatable having same column names. i am trying to copy data of one data table to another.
The destination datatable has one datetime column and source datatble has datecolumn.
but my code is not working.

dtequityData is source datatable
drnew is new row created for destination table
foreach (DataRow dr in _dtequityData.Rows)
{
drnew["fldDate"] =Convert.ToDateTime((dr["flddate"]).ToString();
}

Thanks in advance...

Your code seems to be updating the same row of the destination table.

foreach (DataRow dr in _dtequityData.Rows)
{
     DataRow r = drnew.NewRow();
     drnew["fldDate"] = Convert.ToDateTime((dr["flddate"]).ToString();
     drnew.Rows.Add(r);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.