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
0

1 Answer 1

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

2
  • Nope, can't be that. I'm just calling the "WorkSheetNoHeaderMethod" and not specifying any columns. And one file sometimes works and sometimes not. Commented Jul 4, 2012 at 15:32
  • Carl, did you ever get this sorted out..??
    – Ads
    Commented Sep 24, 2013 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.