Command.executeScale () typically returns the Object type, but we often convert it into a corresponding database field type. For example, Oracle Database Field Type is Numeric, with int result = (int) Command.executeScale (); will trigger InvalidCastException. There are two methods at this time:
1. Use int results = int.parse (Command.executeScale (). TOSTRING ());
2. Change to Decimal, Decimal Result = (Decimal) Command.executeScale ();
Obvious method 2 is better than method 1.
Sometimes ExecuteScale () returns NULL, you can write the corresponding code with Catch (NullReferenceException).