Solved

converting SQL money to Double variable chopes of zeros  c#

Posted on 2007-04-06
4
951 Views
Last Modified: 2012-06-21
I have a SQL Table Column whos data type is money...
I convert that to a double for working with as a variable...

Problem I am having is that it chops off zero's
WHen I convert the money to Double if the money is 3.5000 t nds up 3.5 but I need it to be 3.50.

Anyone know how I can do this in the conversion
0
Comment
Question by:Prysson
  • 2
  • 2
4 Comments
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 18869044
3.5000 t nds up 3.5 but I need it to be 3.50.


what does this mean

if ur money is

3.54600 it will show as 3.546 and if its
3.00000 it will show as 3

but how does that make a difference both are double rt

0
 

Author Comment

by:Prysson
ID: 18869821
I need the value to display in a standard dollar format

2.00
3.00
3.50
3.70

not
2
3
3.5
3.7

So in short I want my variable to hold onto two decimal places in the number regardless of whether they are zero's or not. I dont want it it truncating it. I need to know how to do this.



etc etc
0
 

Author Comment

by:Prysson
ID: 18870749
The Solution I was looking for was actual a problem of presenting the data in the presentation layer. Basically I needed to convert the doubel to a string("c"0

double d = 2.5;
string s = d.ToString("c");

s = $2.50
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 18871584
u could do this then

string str = double.ToString("0,0.00");
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now