0

Using breakpoints I found that the problem starts when the searching process reaches dAdapter.Fill(ds);. The exception is "Couldn't find install-able ISAM".

function starts here
{
    try
    {
        string startPath = directorytbx.Text.ToString() + @":\Windows Data Management System\";
        // string[] oDirectories = Directory.GetDirectories(startPath, nametbx.Text + ".xls", SearchOption.AllDirectories);
        DirectoryInfo info = new DirectoryInfo(startPath);
        DirectoryInfo[] arry = info.GetDirectories();
        List<string> listOfFolderNames = new List<string>();
        foreach (DirectoryInfo dInfo in arry)
        {
            listOfFolderNames.Add(dInfo.Name);
        }
        List<string> finalPaths = new List<string>();
        foreach (string checker in listOfFolderNames)
        {
            if (checker.ToUpper().Contains(nametbx.Text.ToUpper()))
            {
                finalPaths.Add(checker);
            }
        }
        int i = 0;
        foreach (DirectoryInfo dInfo in arry)
        {
            DirectoryInfo dsubInfo = new DirectoryInfo(dInfo.FullName + "\\");
            FileInfo[] dsubInfoArray = dsubInfo.GetFiles();

            String name = dsubInfo + "\'" + dsubInfoArray[1].ToString();

            //String constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +dsubInfoArray + ";Extended Properties='Excel 12.0 XML;HDR=YES;';";

            //string PathConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dsubInfoArray + ";Extended Properties='Excel 12.0 XML;HDR=YES;';";

            //create the "database" connection string 
            string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + name + ";Excel 12.0 Xml;HDR=YES";

            //create the database query
            string query = "SELECT * FROM [Sheet1$]";

            //create an OleDbDataAdapter to execute the query
            OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);
            DataSet ds = new DataSet();
            dAdapter.Fill(ds);
            //fill the DataTable
            DataTable data = ds.Tables[0];
            dAdapter.Fill(data);
            dataGridView1.DataSource = data;
            dAdapter.Dispose();

            i++;
        }
    }
    catch (Exception ex)
    {
        errlbl.Show();
        errlbl.Text = "Error: " + ex.Message;
    }
}
halfer
  • 19,824
  • 17
  • 99
  • 186
  • there are known issues with the Microsoft.Jet..OLEDB.4.0 in connection with systems where 64 bit office is installed. find the proper combination of MS Office bitness, Data Access Components, and provider string, and the exception will be resolved. – Cee McSharpface Aug 19 '17 at 13:24
  • Possible duplicate of [System.Data.OleDb.OleDbException: Could not find installable ISAM](https://stackoverflow.com/questions/11562267/system-data-oledb-oledbexception-could-not-find-installable-isam) – mjwills Aug 19 '17 at 13:25
  • Possible duplicate of [Error: "Could Not Find Installable ISAM"](https://stackoverflow.com/questions/512143/error-could-not-find-installable-isam) – Cee McSharpface Aug 19 '17 at 13:25
  • Thank You! I'll try your suggestion and will let you know. Thanks again :) – Abdul Hanan Aug 19 '17 at 13:26

0 Answers0