简体   繁体   English

c#Btrieve 6.15错误22

[英]c# Btrieve 6.15 error 22

I use the following code to collect data from a BTrieve 6.15 database file based on the WBTRV32.dll I get allways the error code 22 back at the position reading the next dataline - is it a Problem that my BTrieve file has not fixed column width's? 我使用以下代码从基于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
                {

                }
            }

} }

The status 22 means "data buffer too short". 状态22表示“数据缓冲区太短”。 As per the documentation : 根据文档

Set the Data Buffer Length to a value greater than or equal to the length of the record you want to retrieve. 将“数据缓冲区长度”设置为大于或等于要检索的记录的长度的值。

You need to make sure the Data Buffer Length is set to the proper value before each call. 您需要确保在每次调用之前将“数据缓冲区长度”设置为正确的值。 In your code, you only set the bufferLength variable once. 在您的代码中,您只需设置一次bufferLength变量。 If you have variable length records, that value is set on return to the length of the record so you, as the developer, know how much data was returned. 如果您有可变长度的记录,则在返回记录长度时会设置该值,因此,作为开发人员,您将知道返回了多少数据。 Before the next GET call, you need to reset it to the maximum you expect to return. 在下一个GET调用之前,您需要将其重置为期望返回的最大值。

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

相关问题 在 C# 代码中使用 W3BTRV7.DLL BTrieve - use W3BTRV7.DLL BTrieve in c# code 使用C#将Btrieve顺序文件转换/读取为人类可读的文本 - Convert / Read Btrieve Sequential file to human readable text using C# C# 使用 VMware SDK 将文件发送到 VM 目录 InitiateFileTransferToGuest 协议错误 --&gt; ResponseStream 错误 22<The File Name is not valid> - C# Sending File to VM Directory using VMware SDK InitiateFileTransferToGuest Protocol Error --> ResponseStream Error 22 <The File Name is not valid> C# 错误:cs(22,1):错误 CS1022:类型或命名空间定义,或预期文件结尾 - C# Error : cs(22,1): error CS1022: Type or namespace definition, or end-of-file expected 如何在C#中将2015年2月19日,22:19:50转换为2015年2月19日22:19:50? - How to convert Feb 19, 2015,22:19:50 to 2/19/2015 22:19:50 in C#? Key Down事件未在C#中触发geckofx 22 - Key Down Event not firing in C# a geckofx 22 在 unity/c# 中捕获关于游戏对象和 OnMessage 的 22 - catch 22 regarding gameobject and OnMessage in unity/c# 使用s22.dll和C#从消息获取LastUID - Get LastUID from message using s22.dll and c# Visual Studio 22 WPF C# MediaElement - 没有媒体显示,但在 Designer 中媒体继续播放 - Visual Studio 22 WPF C# MediaElement - No Media is showing up but in Designer the media keeps playing 不知不觉地泛滥? - Btrieve without Pervasive?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM