It's working fine till the line " oleda.Fill(ds);" when debugger reach that line, it doesn't show any error or exception just throw back to the View (HTML Page). I'm unable to understand the source of exception. Can anyone please guide me.
public class OledbRepository
{
private string _connectionString;
public OledbRepository(string filePath)
{
_connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';";
}
public DataTable Invoke(string sheetName)
{
DataTable result;
using (var connection = new OleDbConnection(_connectionString))
{
OleDbCommand cmd = new OleDbCommand("SELECT * FROM " + sheetName, connection);
OleDbDataAdapter oleda = new OleDbDataAdapter() { SelectCommand = cmd };
DataSet ds = new DataSet();
oleda.Fill(ds);
result = ds.Tables[0];
}
return result;
}
}