繁体   English   中英

c#Btrieve 6.15错误22

[英]c# Btrieve 6.15 error 22

我使用以下代码从基于WBTRV32.dll的BTrieve 6.15数据库文件中收集数据,但始终将错误代码22返回到读取下一条数据线的位置-这是我的BTrieve文件未固定列宽的问题吗?

// Open file
RecordBuffer dataBuffer = new RecordBuffer();
int bufferLength = System.Runtime.InteropServices.Marshal.SizeOf(dataBuffer);
short status = (short)BTRCALL(0, positionBlock, ref dataBuffer, ref bufferLength, fileNameArray, 0, 0);

        if (status == 0) <== Here Status = 0
        {
            // Get first record
            dataBuffer = new RecordBuffer();
            status = (short)BTRCALL(12, positionBlock, ref dataBuffer, ref bufferLength, fileNameArray, 0, 0); //BGETFIRST

            if (status == 0) <== Here Status = 0
            {
                ...                
            }

            // Get subsequent records
            while (status == 0) // BReturnCodes.END_OF_FILE or an error will occur
            {
                dataBuffer = new RecordBuffer();
                status = (short)BTRCALL(6, positionBlock, ref dataBuffer, ref bufferLength, fileNameArray, 0, 0); //BGETNEXT

                if (status == 0) <=== Here Status = 22 data buffer length overrun
                {

                }
            }

}

状态22表示“数据缓冲区太短”。 根据文档

将“数据缓冲区长度”设置为大于或等于要检索的记录的长度的值。

您需要确保在每次调用之前将“数据缓冲区长度”设置为正确的值。 在您的代码中,您只需设置一次bufferLength变量。 如果您有可变长度的记录,则在返回记录长度时会设置该值,因此,作为开发人员,您将知道返回了多少数据。 在下一个GET调用之前,您需要将其重置为期望返回的最大值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM