0

I need to convert a _bstr_t that comes from the DB (ADO) to float, have a look at the code segment:

_bstr_t valueDB = productsDB->Fields->GetItem("Value")->Value;
float referenceFloatValue = productsDB->Fields->GetItem("Value")->Value.fltVal;

I'm trying to use .fltVal, but it's not working (before the instruction the value of referenceFloatValue's 0.0, (different value of valueDB). Does anybody know what I need to do? Thanks

MGE
  • 872
  • 1
  • 8
  • 14

1 Answers1

0

You can use wcstod(valueDB); but you have to sanitize the string before ( ensure it is not null, ensure it is written in properly format ) otherwise you get in troubles. Maybe is not up to you, but in general is better if a field has to represent a number, to be defined to contain a number. Have a look here: http://msdn.microsoft.com/en-us/library/kxsfc1ab.aspx

Felice Pollano
  • 32,832
  • 9
  • 75
  • 115