Board index » delphi » string to currency question

string to currency question

I have a paradox table with a currency field . I want to save a string
expression ('999.99' by example) in that field. If i use :
dataset['dollar'].asstring := mystringvalue    get a exception saying:
"variant convert not supported" or some like that. What is the correct way
to do that??

Thanks in advance...

 

Re:string to currency question


datasetfield.value:=StrToFloat(mystringvalue)

Quote
Germn Gentile wrote in message <677jhm$a...@forums.borland.com>...
>I have a paradox table with a currency field . I want to save a string
>expression ('999.99' by example) in that field. If i use :
>dataset['dollar'].asstring := mystringvalue    get a exception saying:
>"variant convert not supported" or some like that. What is the correct way
>to do that??

>Thanks in advance...

Re:string to currency question


Quote
Germn Gentile wrote:

> I have a paradox table with a currency field . I want to save a string
> expression ('999.99' by example) in that field. If i use :
> dataset['dollar'].asstring := mystringvalue    get a exception saying:
> "variant convert not supported" or some like that. What is the correct way
> to do that??

> Thanks in advance...To use the .AsString property, you need to refer to the field differently:

either
Dataset.Fields(1).AsString
or
Dataset.FieldByName('dollar').AsString

You may note that Delphi's help suggests that you not use these properties
to set values, however.  I'm not sure if they're slower than using .Value
or if you are more likely to get in a situation where you generate an error,
like trying to assign a string word to a currency field.

Good luck,  Brian

Other Threads