1

Sometimes when running the code below it results in the error IErrorInfo.GetDescription failed with E_FAIL(0x80004005) from the call to excelFile.WorksheetNoHeader(0).

It doesn't seem to depend on the excel file, one file can be readable one time and the next time not.

Any ideas what could be the cause?

    Public Overrides Function GetImportDataAsDataTable() As DataTable
        Dim dataTable = New DataTable
        dataTable.BeginLoadData()
        Try
            Dim excelFile = New ExcelQueryFactory(FileFullPath)
            For Each importDataRow In excelFile.WorksheetNoHeader(0)
                If dataTable.Columns.Count = 0 Then
                    For i = 1 To importDataRow.Count
                        dataTable.Columns.Add(New DataColumn())
                    Next
                End If
                Dim dataRow = dataTable.NewRow
                dataRow.ItemArray = importDataRow.ToArray
                dataTable.Rows.Add(dataRow)
            Next
        Finally
            dataTable.EndLoadData()
        End Try
        Return dataTable
    End Function
mmot
  • 187
  • 8
Carl Björknäs
  • 593
  • 4
  • 15

1 Answers1

1

It's an OleDb error.

It looks like a reserved sql word was used. Check out this post for more information: http://forums.asp.net/t/1225443.aspx/1

Paul
  • 18,349
  • 7
  • 49
  • 56