Articles → ADO.NET → Reading CSV Files In Ado.Net
Reading CSV Files In Ado.Net
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