Microsoft Access OledbDataReader read values error

465 views Asked by At

I am connecting to MS Access file with jet Engine x64,but also worked x86 platform. I am getting error while trying to read data

            long sizeCounter = 0, rowIndex = 0;
            var secondValues = new object[BatchSize][];

            for (var secondIndex = 0; secondIndex < secondValues.Length; secondIndex++)
                secondValues[secondIndex] = new object[reader.FieldCount];

            while (reader.Read())
            {
               //TODO:Error get from here...
                reader.GetValues(secondValues[sizeCounter]);

                sizeCounter++;

                if (NotifyAfter > 0 && (rowIndex % NotifyAfter == 0 && rowIndex > 0 && RowsCopied != null))
                {
                    RowsCopied(this, new RowsCopiedEventArgs(rowIndex));
                }

                if (sizeCounter == BatchSize)
                {
                    RunBulkCopy(secondValues);

                    sizeCounter = 0;
                }

                rowIndex++;
            }

            var lastValues = new object[sizeCounter][];

            for (var lastIndex = 0; lastIndex < sizeCounter; lastIndex++)
                lastValues[lastIndex] = secondValues[lastIndex];

            RunBulkCopy(lastValues);

            if (RowsCopied != null)
                RowsCopied(this, new RowsCopiedEventArgs(rowIndex));
        }
        catch (Exception)
        {
            if (RowsCopied != null)
                RowsCopied(this, new RowsCopiedEventArgs
                {
                    Abort = true
                });
        } 

Unable to cast COM object of type 'System.__ComObject' to interface type 'IRowset'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0C733A7C-2A1C-11CE-ADE5-00AA0044773D}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

Thanks!

1

There are 1 answers

1
Sherzod Mutalov On

OleDb data connector has a bug when used in multi-threaded projects.The exception throws when you create OleDb object in STA apartment and call it from MTA.

Microsoft report of the issue