Replies: 1 comment 6 replies
-
@MaceWindu Can I look at your usage of APIs to figure out whether adding this check is possible or not? e.g. If SqlParameter is being used to add a value, without specifying the type (SqlDbType), then the driver will send the information as-is to the server, because the Driver has no idea about the schema of the table on the server. Hence for many of these cases, where the driver is unsure about the intended SqlType, the server performs the conversion to the appropriate column type. In such cases, the driver relies on the server to send back any error messages to be surfaced to the application. SqlTypes are likely the right choice, in case the application knows about the column type on the server, and I see that SqlTypes when instantiated, validate the datatype as well. |
Beta Was this translation helpful? Give feedback.
-
Recently we've got following error (due to error on our side) when passing
double.NaN
as parameter valueThe incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 3 ("@p"): The supplied value is not a valid instance of data type float. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision.
We were already aware of issue so it was easy to understand what's wrong, but in general this message is way to low-level for this situation.
Is it possible to add validation for float/double parameters against
NaN
/Infinity
values on provider side so users get more easy-to-understand message?I see that client already has such validation for some code:
SerializeDouble
has validation (not sure which code path use it, I see it related to encryption somehow)https://github.com/dotnet/SqlClient/blob/main/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs#L1915-L1925
and
WriteDouble
hasn'thttps://github.com/dotnet/SqlClient/blob/main/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs#L1927-L1932
Beta Was this translation helpful? Give feedback.
All reactions