xsharp.eu • Convert Object -> Numeric - Page 2
Page 2 of 2

Convert Object -> Numeric

Posted: Sat Mar 02, 2019 11:36 am
by robert
I would write

Code: Select all

if npgresult IS Decimal
     nValue:= (int)npgresult // No need to try with Value property.
endif
Robert

PS In the next build you can also use the IS pattern

Code: Select all

IF npgResult is Decimal dValue
   // now there is a local dValue of type Decimal with the value from npgResult
  nValue := (INT) dValue   // the compiler now knows that you are converting a decimal to an int
endif
Robert

Convert Object -> Numeric

Posted: Sat Mar 02, 2019 12:58 pm
by Frank Müßner
Hi Johann;
lumberjack wrote: Ok I understand, why still VO usual?
PS: My German is improving... :)
because i don´t know what i am getting from the select. :-(

Historie:
In VO Code, i use (VO2ADO) Adoserver to get one Value from a Table. Then i get with AdoServer:RecordSet:Fields:Item(1):Type, the Type of the Column an can handle and modify this.

When Transport to X# i try to replace this with .Net Postgresql Provide, only for this type of getting one Value from Table.
and there comes the Problem with getting the right DataType. Sample, Decimals come as Object.

But i have with Karl-Heinz code solve this.



@ Robert,
if npgresult IS Decimal
nValue:= (int)npgresult // No need to try with Value property.
endif
not work, because npgresult is Object. when get Numeric Values from PG.

But i have now solved the Problem with Karl-Heinz Code.
Perhaps some not work, because i have VN3 Runtime.
I wait for VX2ADO and then use the X# Runtime, and try to transport my main App. :-)
Regards, Frank