Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error Reading Excel File To DataSet
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Titre:
Error Reading Excel File To DataSet
Divers
Thread ID:
01429441
Message ID:
01429441
Vues:
286
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
Répondre
Fil
Voir

Click here to load this message in the networking platform