.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum


Posted By: Ilkin     Posted Date: March 28, 2013    Points:5   Category :C#

Below I showed my example where i try to add first table field values to secodn table. According to second table column name.Want to say , if first table FIELD_ID = second table column name then add.if any idea help please

DataTable dt = new DataTable();
dt.Columns.Add("Field_ID", typeof(Int32));
dt.Columns.Add("Field", typeof(String));
dt.Rows.Add(new object[] { 1, "Masin" });
dt.Rows.Add(new object[] { 2, "Tank" });
dt.Rows.Add(new object[] { 3, "Helicopter" });

DataTable dt2 = new DataTable();
dt2.Columns.Add("1", typeof(String));
dt2.Columns.Add("2", typeof(String));

Thanks in advance.

Author: Narayanan             
Posted Date: April 01, 2013     Points: 20   

Hi ,
AS my Understand, you want to add One Data Table into another Data Table that means you want to Copy the Data from one table into another table

try this Code:

foreach (DataRow dr in dataTable1.Rows) {
if (/* some condition */)

Regards, Lakshmi Naraayanan.S

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend