Today, we have a service request that our customer faced the following error message: System.InvalidCastException: Specified cast is not valid reading a Resultset or doing any operation with the database.
Following, I would like to share my lessons learned with this issue.
create procedure MyCodeTest(@state as int)
as select @state
So, all points to, depending on, the value that the ResultSet is reading or the code conversion that is using is not the expecting values. In terms of coding, for example, in SQL Server TSQL we have TRY_PARSE (Transact-SQL) - SQL Server | Microsoft Learn to check the value conversion test before executing the conversion.
Enjoy!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.