I have been digging from last 4 hours to find a simplest solution to import a csv file into datagridview in C# and i am unable to find the appropriate solution.
then hopelessly, I decided to ask user to convert csv to excel first and then import but its too unromantic. here is the code for importing excel:
string pathConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + txtPath.Text + ";Extended Properties=\"Excel 8.0;HDR=Yes;\";";
OleDbConnection conn = new OleDbConnection(pathConn);
OleDbDataAdapter ODA = new OleDbDataAdapter("Select *from [" + txtSheet.Text + "$]", conn);
DataTable dt = new DataTable();
ODA.Fill(dt);
dataGridView1.DataSource = dt;
Question: To import CSV, what should be the connectionString using this code.? Or there is no simple soultion?