Système.Les données.OleDb.OleDbException: impossible de trouver le ISAM installable

J'ai écumé le net et trouvé beaucoup de gens demander cela, mais aucun n'a fixé ma réponse.

J'ai une Classe de Connexion, et une Méthode qui utilise cette Classe dans une page.

DataConn.cs

public static OleDbConnection ConnectExcel()
{
    //Store the connection details as a string
    string connstr =
        String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=pricelist.xlsx;Extended Properties=Excel 12.0 Xml;HDR=YES");

    //Initialise the connection to the server using the connection string.
    OleDbConnection oledbConn = new OleDbConnection(connstr);

    //Open the connection, we do this here so we can instantly be able to use SQL commands in the code.
    oledbConn.Open();

    return oledbConn;
}

public static void DisconnectExcel()
{
    _oledbConn.Dispose();
    _oledbConn.Close();
}

Et le code qui l'appelle

protected void Page_Load(object sender, EventArgs e)
{
    //Connection String
    const string xlStr = "SELECT * FROM [Sheet2$]";

    //Create OleDbCommand object and select data from worksheet Food
    OleDbCommand cmd = new OleDbCommand(xlStr, DataConn.ConnectExcel());

    //Create new OleDbDataAdapter
    OleDbDataAdapter oleda = new OleDbDataAdapter();

    oleda.SelectCommand = cmd;

    //Create a DataSet which will hold the data extracted from the worksheet.
    DataSet ds = new DataSet();

    //Fill the DataSet from the data extracted from the worksheet.
    oleda.Fill(ds);

    //Bind the data to the GridView
    gridPricelist.DataSource = ds;
    gridPricelist.DataBind();
}

Oui, je reçois TOUJOURS:

Système.Les données.OleDb.OleDbException: impossible de trouver le ISAM installable.

Quelqu'un peut s'il vous plaît aider?

Sur les colonnes de droite de cette question, vous trouverez des dizaines de questions identiques à la vôtre.

OriginalL'auteur TheGeekZn | 2012-07-19