Missing a digit

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

When I store a real value to a string variable using the OleDbDataReader
like so :

myValStrg = rdr.getValue(2).ToString()

how do I preserve the trailing zero ?

Any other trailing number is preserved.

Thanks,
 
Hi Gordon,

Why are you storing a real value to a string one?
You should store it to real variable (float perhaps) and use UI formatting
to display whatever format you want.
 
Hi

When I store a real value to a string variable using the OleDbDataReader
like so :

myValStrg = rdr.getValue(2).ToString()

how do I preserve the trailing zero ?

Any other trailing number is preserved.

Thanks,
By trailing zero, do you mean the zero that is like this ( 21.0 )?
If you want to preserve the zero you will need to format the string like this:
float i = 21.0F;
string s = i.ToString("0.0");
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 
Hi

When I store a real value to a string variable using the OleDbDataReader
like so :

myValStrg = rdr.getValue(2).ToString()

how do I preserve the trailing zero ?

Any other trailing number is preserved.

Thanks,

Try this:

myValStrg = rdr.getValue(2).ToString("#.00")
 
Thanks,

I tried your suggestion but the tostring() won't allow me to pass a
formatting string ?

Ah, sorry.

getValue is more generic

Try this instead

myValStrg = rdr.GetDouble(2).ToString("#.00")
 
Ah, I missed the part about why you're parsing each column that's returned?
If you're being paid by the line, then nevermind... ;)

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
 
Because GetValue returns an object. If you want to avoid an intermediate
variable then you should use a strong typed GetXXX method.
 
Hi;

This did not work :
holdVal = rdr.getval(2).toString("#.00")

This did :
holdVal = rdr.getval(2)
holdAdjString = holdVal.tostring("#.00")

I will try your suggestion too.

Thanks

Give it a go. I'll eat my hat if it doesn't work :)
 
Back
Top