title: Merge columns of two CSV files in C#.net
body: <p>I've been working in a project that needs to import two .CSV file and merge it.<br>
  I've used <code>CachedCsvReader</code> and <code>StreamReader</code> to import the CSV1 and CSV2 file in <code>dataGridView1</code> and <code>dataGridView2</code> and it works perfectly. Now I need two merge these two dataGridView or the CSV files in <code>dataGridView3</code>. I've tried many different techniques throughout the web to solve it but nothing works.<br>
  For example, I've used <code>Excel.Application</code>,Workbook and Worksheet things to solve it and also the dataGridView methods but nothing works. Can anyone Please help me?!! It would be really Appreciated!! By the way, the header of each column is written below the header name like A, B, C, the names are below them in the first (1) row.</p>
  
  <p>For your convenience, I'm adding the small part that I've done so far below,</p>
  
  <pre><code>using (CachedCsvReader csv1 = new CachedCsvReader(new StreamReader(textBox1.Text), true))
  {
      dataGridView1.DataSource = csv1;
  }
  </code></pre>
  
  <p>After the suggestion of Mr. Damith I did this:</p>
  
  <pre><code>OleDbConnection conn1 = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + System.IO.Path.GetDirectoryName(textBox1.Text) +"; Extended Properties = \"Text;HDR=YES;FMT=Delimited\"");
           conn1.Open();
           OleDbDataAdapter adapter1 = new OleDbDataAdapter("SELECT * FROM " + System.IO.Path.GetFileName(textBox1.Text), conn1);
           DataSet ds1 = new DataSet("Temp"); 
           adapter1.Fill(ds1);
          // you can get datatable as bellow 
           DataTable tb1 = ds1.Tables[0];
  
           OleDbConnection conn2 = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + System.IO.Path.GetDirectoryName(textBox2.Text) + "; Extended Properties = \"Text;HDR=YES;FMT=Delimited\"");
           conn2.Open();
           OleDbDataAdapter adapter2 = new OleDbDataAdapter("SELECT * FROM " + System.IO.Path.GetFileName(textBox2.Text), conn2);
           DataSet ds2 = new DataSet("Temp");
           adapter2.Fill(ds2);
           // you can get datatable as bellow 
           DataTable tb2 = ds2.Tables[0];
  
          //Merge
           tb1.Merge(tb2);
  
          //View dataGridView 3
           dataGridView3.DataSource = tb1;
           dataGridView3.Update();
  </code></pre>
  
  <p>Now with the content, click the link below to download the Text file of the example.
  <a href="http://www.adrive.com/public/AcvH2U/example.txt" rel="nofollow">Click here to download the .txt file</a></p>
  
  <p>I hope this might help you.
  Thanks!
  -Saffan.</p>