diff --git a/src/AdoNetCore.AseClient/Enum/TdsDataColumnStatus.cs b/src/AdoNetCore.AseClient/Enum/TdsDataColumnStatus.cs new file mode 100644 index 00000000..6a87c64d --- /dev/null +++ b/src/AdoNetCore.AseClient/Enum/TdsDataColumnStatus.cs @@ -0,0 +1,22 @@ +using System; +// ReSharper disable InconsistentNaming + +namespace AdoNetCore.AseClient.Enum +{ + [Flags] + internal enum TdsDataColumnStatus : byte + { + /// + /// No Data follows, the value is NULL. + /// + TDS_DATA_COLUMNSTATUS_NO_DATA = 0x01, + /// + /// This data value is corrupted due to Overflow/Underflow. + /// + TDS_DATA_COLUMNSTATUS_CORRUPTED = 0x02, + /// + /// This data value has been truncated or rounded. + /// + TDS_DATA_COLUMNSTATUS_TRUNCATED = 0x04, + } +} diff --git a/src/AdoNetCore.AseClient/Internal/ValueReader.cs b/src/AdoNetCore.AseClient/Internal/ValueReader.cs index 721fdbf7..b5b4ed8b 100644 --- a/src/AdoNetCore.AseClient/Internal/ValueReader.cs +++ b/src/AdoNetCore.AseClient/Internal/ValueReader.cs @@ -61,6 +61,15 @@ private static object ReadInternal(Stream stream, FormatItem format, DbEnvironme { if (ReadMap.ContainsKey(format.DataType)) { + // If the TDS_DATA_COLUMNSTATUS request capability is enabled, then all datatype representations begin with a status byte + if (format.RowStatus.HasFlag(RowFormatItemStatus.TDS_ROW_COLUMNSTATUS)) + { + var columnStatus = (TdsDataColumnStatus)stream.ReadByte(); + if (columnStatus.HasFlag(TdsDataColumnStatus.TDS_DATA_COLUMNSTATUS_NO_DATA)) + { + return DBNull.Value; + } + } return ReadMap[format.DataType](stream, format, env) ?? DBNull.Value; }