[英]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.