Microsoft Access OledbDataReader读取值错误

本文关键字:错误 读取 OledbDataReader Access Microsoft | 更新日期: 2023-09-27 17:59:47

我使用jet Engine x64连接到MS Access文件,但也使用x86平台。我在尝试读取数据时出错

            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
                });
        } 

无法强制转换类型为"System"的COM对象__ComObject到接口类型"IRowset"。此操作失败,因为QueryInterface调用关于与IID接口的COM组件由于以下原因,"{0C733A7C-2A1C-11CE-ADE5-00AA004773D}"失败错误:不支持此类接口(HRESULT中的异常:0x80004002(E_NOINTERFACE))。

谢谢!

Microsoft Access OledbDataReader读取值错误

OleDb数据连接器在多线程项目中使用时存在错误。当您在STA单元中创建OleDb对象并从MTA调用它时,会引发异常。

Microsoft关于问题的报告