Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error Reading Excel File To DataSet
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Error Reading Excel File To DataSet
Miscellaneous
Thread ID:
01429441
Message ID:
01429441
Views:
284
I'm trying to read an excel file into a dataset. I'm getting "Not a legal OleAut date.". I Googled it, and I don't see anything wrong with the data in the excel file.

Here's the code:
public DataSet ExcelToDataSet(string ExcelFile, string SheetName)
{
    DataSet ds = new DataSet();

    string ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ExcelFile + ";Extended Properties=Excel 8.0;";

    OleDbConnection Conn = new OleDbConnection(ConnString);

    try
    {
        Conn.Open();
    }
    catch(Exception e)
    {
    }

    string Select = "SELECT * FROM [" + SheetName + "$]";
    OleDbCommand Command = new OleDbCommand(Select, Conn); 
    OleDbDataAdapter Adapter = new OleDbDataAdapter();
    Adapter.SelectCommand = Command;
    Adapter.Fill(ds); 
    
    Conn.Close();

    return ds;
}
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Reply
Map
View

Click here to load this message in the networking platform