I am using the below two codes to read the csv file but it returns the same error.
'E:\business\business\Document\4112013\20580.csv' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
I'm not able to fix this issue. Plese help me to solve this
SaveLocation = @"E:\business\business\Document\4112013\20580.csv";
string connStr = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=@" + SaveLocation + ";Extended Properties=\"Text;HDR=YES;FMT=Delimited\"";
OleDbConnection conn = new OleDbConnection(connStr);
conn.Open();
// give full path to the file here
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM " + SaveLocation, conn);
DataSet ds = new DataSet("QueryCSV");
adapter.Fill(ds);
DataTable dt = ds.Tables[0];
System.Data.OleDb.OleDbDataAdapter MyCommand = default(System.Data.OleDb.OleDbDataAdapter);
System.Data.OleDb.OleDbConnection MyConnection = default(System.Data.OleDb.OleDbConnection);
//MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0; " + "data source=" + SaveLocation + "; " + "Extended Properties=Excel 12.0;");
//MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0; " + "data source=" + SaveLocation + "; " + "Extended Properties='csv;HDR=Yes;FMT=Delimited(,)';");
MyConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + SaveLocation + ";Extended Properties=\"Text;HDR=YES;FMT=Delimited\"");
MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet5$]", MyConnection);
ds = new System.Data.DataSet();
MyCommand.Fill(ds);