Search code examples
webformsoledboledbconnection

Could not find installable ISAM while opening excel file with OLE driver


I am getting a "Could not find installable ISAM" error in the asp.net webform using visual basic. I am using .Net 4.6 framework. I tried different combinations of connection strings and I also tried with a single quote on Extended Properties as many online solutions suggested but the error did not go away. My code is as below:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim conn As OleDbConnection
        Dim dta As OleDbDataAdapter
        Dim dts As DataSet
        Dim excel As String
        excel = "C:\Users\ishfaq.babar\Downloads\aaa.xlsx"
        'Dim openfiledialog As New OpenFileDialog
        'conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excel + ";Extended Properties='Excel 12.0;'";")

        conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\ishfaq.babar\Downloads\aaa.xlsx;Extended Properties='Excel 12.0;HDR=YES;Persist Security Info=False'")
        dta = New OleDbDataAdapter("select * from [Sheet1$]", conn)
        dts = New DataSet
        dta.Fill(dts, "[Sheet1$]")
        ExcelGridData.DataSource = dta
        ExcelGridData.DataBind()
    End Sub

i got error on line

dta.Fill(dts, "[Sheet1$]")

Moreover,I have installed both versions of ole drivers x64 and X86 and I had installed ole driver by command line as:

accessdatabaseengine /quiet

accessdatabaseengine_X64 /quiet

Because I was getting error from GUI Installer as:

microsoft.ace.oledb.12.0' provider is not registered on the local machine

ScreenShot of installed drivers is as follows:

OLE Drivers.Installed Access database Engine versions


Solution

  • ERROR has been resolved automatically with no change in code at all. Just after login again to my account after taking a break it runs successfully:

    EDIT:

    I Put conn.Open() after connection string.

    New Code is As Below:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim conn As OleDbConnection
            Try
    
                Dim dta As OleDbDataAdapter
                Dim dts As DataSet
                Dim excel As String
                excel = "C:\Users\ishfaq.babar\Downloads\aaa.xlsx"
                'Dim openfiledialog As New OpenFileDialog
                'conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excel + ";Extended Properties='Excel 12.0;'";")
    
                conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\ishfaq.babar\Downloads\aaa.xlsx;Extended Properties='Excel 12.0;HDR=YES;Persist Security Info=False'")
                conn.Open()
                'PrintLine('ok')
                ' conn.Close()
                dta = New OleDbDataAdapter("select * from [Sheet1$]", conn)
                dts = New DataSet
                dta.Fill(dts, "[Sheet1$]")
                ExcelGridData.DataSource = dta
                ExcelGridData.DataBind()
            Catch ex As Exception
                conn.Close()
            End Try
        End Sub
    

    Read data successfully from excel file as below screenshot:

    Result of data read from excel file