The following C# method will throw exception " when converting an object to decimal data type:
public static T ComputeVariableValue<T>(string stmt)
{
DatabaseManager dbMgr = ConfigurationBasedFactory.Current.GetInstance<DatabaseManager>("DataStore");
DatabaseResult set = dbMgr.Execute( DatabaseExecutionType.Scalar, CommandType.Text, stmt);
return (T)set.ResultScalar;
}
[System.InvalidCastException] = {"Specified cast is not valid."}