[DUG] interesting issue in .NET
jamessugrue at xtra.co.nz
jamessugrue at xtra.co.nz
Fri Jan 5 12:00:30 NZDT 2007
I am assuming rdr is a DataReader. It returns an object. You will have to explicitly convert it using System.Convert.ToDecimal, ToSingle - whatever you want
I'm guessing that .NET thinks object is too ambiguous to use a boxing cast. BTW if you want to convert to String you could try (should work doing OTOH)
string s = String.Format("{0:c}", rdr[Amount]);
---- Jeremy Coulter <vss at vss.co.nz> wrote:
> Hi all.
> I have come across an issue that I am not sure about in .NET
>
> I have a value being returned from a stored procedure. Tha value is a
> decimal value, i.e. 511.34
>
> But when I do this :- system.Double(rdr['AMOUNT']).ToString('C');
> (converting it to a currency format)
>
> I get an error "Specified cast is not valid" yet I know there IS a value
> being passed in, and it IS a double.
>
> anyone know WHY?
>
> Thanks, Jeremy
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.16.5/616 - Release Date: 04/01/2007
> 13:34
>
More information about the Delphi
mailing list