//varDecimal = $000E; { vt_decimal 14 } {UNSUPPORTED as of v6.x code
base}
It seem that delphi7 does not support decimal type of variant.
:(
Now, I use ADOInt._Recordset to open a recordset from MS SQLServer, my
recordset(var RS: _Recordset) include one field(FieldName is 'Amount') which
fieldType is adDecimal(declare in adoint.pas), but it is not supported by
delphi7. the follwing codes will raise exception:
if RS.Field['Amount'].Value > 0 then //raise exception
begin
...
end;
How can I do? How can I make delphi7 support vardecimal? why delphi7 remove
vardecimal type of Variant?
Thanks!!!
It did not remove it, you misinterpret the comment. It was never
supported by Delphi, D5 did not even define a constant for it.
DECIMAL is not an automation-compatible data type, MS added it
specifically for SQL Server support via ADO.
It is possible to work with unsupported variant types in Delphi, but it
is cumbersome. The first thing you have to do is test the actual data
type of the variant.
uses ActiveX; // this unit declares the API functions for variant
manipulation
var
V: OleVariant;
Value: Double;
...
V:= RS.Field['Amount'];
if VarType(V) = varDecimal then begin
OleCheck(VarR8FromDec(TVarData(V).varAny, Value));
if value > 0 then
....
end;
This technique becomes particularly painful when the automatic variant
cleanup Delphi does on V above blows up as well. In such a case you
have to call
VariantClear(V);
explicitely.
--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
"Peter Below (TeamB)" <none>
??????:xn0f1d57...@newsgroups.borland.com...