Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Datatable Concatination

Datatable Concatination

Scheduled Pinned Locked Moved ASP.NET
tutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sekannak
    wrote on last edited by
    #1

    Hi, I have 3 different Datatable with different coloumns, i want to concatinate with 3 tables into a single table , but i dont want to merge how can achieve this, datatable1 datatable2 datatable3 1st table 5 columns 2nd table 7 columns 3rd table 3 coloumn for (i=0 to 3) { for(j=0 to datatable1.columns.count-1) { dr1[j]=j; } for(j=0 to datatable2.columns.count-1) { dr2[j]=j; } for(j=0 to datatable3.columns.count-1) { dr3[j]=j; } } So finally i want to concatinate with the 3 table with 3 rows... note: I dont want to merge.. How to do this... Plz answer me... thanks in Advance.. kannak......

    kannak

    A 1 Reply Last reply
    0
    • S sekannak

      Hi, I have 3 different Datatable with different coloumns, i want to concatinate with 3 tables into a single table , but i dont want to merge how can achieve this, datatable1 datatable2 datatable3 1st table 5 columns 2nd table 7 columns 3rd table 3 coloumn for (i=0 to 3) { for(j=0 to datatable1.columns.count-1) { dr1[j]=j; } for(j=0 to datatable2.columns.count-1) { dr2[j]=j; } for(j=0 to datatable3.columns.count-1) { dr3[j]=j; } } So finally i want to concatinate with the 3 table with 3 rows... note: I dont want to merge.. How to do this... Plz answer me... thanks in Advance.. kannak......

      kannak

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      Use this :

      DataTable dt = datatable1.clone();

      foreach(DataColumn dc in datatable2.Columns)
      {
      DataColumn dc1 = new DataColumn(dc.Caption,dc.DataType);
      dt.Columns.add(dc1);
      }

      foreach(DataColumn dc in datatable3.Columns)
      {
      DataColumn dc1 = new DataColumn(dc.Caption,dc.DataType);
      dt.Columns.add(dc1);
      }

      Now to merge the data you need to

      for(i=0;i

      Finally
      dt.Rows.Add(drNew)

      You can also make it more cleaner. Also change it according to your need.
      Hope it works :) :) :)

      Abhishek Sur


      My Latest Articles
      **Create CLR objects in SQL Server 2005
      C# Uncommon Keywords
      Read/Write Excel using OleDB

      **Don't forget to click "Good Answer" if you like to.

      modified on Friday, September 18, 2009 1:49 PM

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups