diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs index 8217604c72..ba650cc932 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -6070,6 +6070,13 @@ internal bool TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, int length, T } catch (Exception e) { + if (stateObj is not null) + { + // call to decrypt column keys has failed. The data wont be decrypted. + // Not setting the value to false, forces the driver to look for column value. + // Packet received from Key Vault will throws invalid token header. + stateObj.HasPendingData = false; + } throw SQL.ColumnDecryptionFailed(columnName, null, e); } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs index 70673ef343..466414c425 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -6884,6 +6884,13 @@ internal bool TryReadSqlValue(SqlBuffer value, } catch (Exception e) { + if (stateObj is not null) + { + // call to decrypt column keys has failed. The data wont be decrypted. + // Not setting the value to false, forces the driver to look for column value. + // Packet received from Key Vault will throws invalid token header. + stateObj._pendingData = false; + } throw SQL.ColumnDecryptionFailed(columnName, null, e); } }