Solved

converting SQL money to Double variable chopes of zeros  c#

Posted on 2007-04-06
4
961 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 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

23 Experts available now in Live!

Get 1:1 Help Now