You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to read binary data stored in VARBINARY (n) type fields #1258
Hello,
Unable to read binary data stored in field BlockData VARBINARY (32,765) .
SortedDictionary<short, byte[]> result = [];
foreach (DataRow dataRow in dataTable.Rows)
{
if (dataRow["BlockNo"] is not short blockNo) { continue; }
object objVal = dataRow["BlockData"];
if(objVal is not byte[] blockData) { continue; }
//if (dataRow["BlockData"] is not byte[] blockData) { continue; }
result[blockNo] = blockData;
}
The value of objVal is always the string 'System. Byte []', the value of blockData is always the null.
Activity
alexluozf commentedon Mar 12, 2026
It's no problem if using FbDbDataReader.
SortedDictionary<short, byte[]> result = [];
while (reader.ReadAsync().Result)
{
short blockNo = reader.GetFieldValue("BlockNo");
byte[] blockData = reader.GetFieldValue<byte[]>("BlockData");
if (blockData != null)
{
result[blockNo] = blockData;
}
}
Thanks a lot.
Alex
cincuranet commentedon Mar 12, 2026
Please provide self-contained runnable code.
alexluozf commentedon Mar 13, 2026
Hello cincuranet,
Please use my test project.
Thanks a lot.
Alex
How to use.zip
FbBinaryFieldAccess.zip
alexluozf commentedon Mar 14, 2026
Hello cincuranet,
Fixed this issue.
method GetSystemType() in src\FirebirdSql.Data.FirebirdClient\Common\DbField.cs
Please review and update the code.
Thanks a lot.
Alex
DbField.zip
alexluozf commentedon Mar 14, 2026
Hello cincuranet,
Should remove case DbDataType.Text.
public Type GetSystemType()
{
switch(DbDataType)
{
case DbDataType.Char:
case DbDataType.VarChar:
{
if(_charset.IsOctetsCharset)
{
return TypeHelper.GetTypeFromDbDataType(DbDataType.Binary);
}
return TypeHelper.GetTypeFromDbDataType(DbDataType);
}
default:
return TypeHelper.GetTypeFromDbDataType(DbDataType);
}
}
DbField.zip