Articles → ADO.NET → Reading CSV files in ADO.NET

Reading CSV files in ADO.NET




Introduction





CSV file



Click to Enlarge




Implementation






  Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<folder_Name>;Extended Properties='text;HDR=Yes';






string connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='text;HDR=Yes';", @"D:\");
string commandText = "select * from abc.csv";
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
  using (OleDbDataAdapter adap = new OleDbDataAdapter(commandText, conn))
  {
    conn.Open();
    using (DataSet ds = new DataSet())
    {
      adap.Fill(ds);
    }
  }
}





Output



Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Sunday, December 18, 2011

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250