Solved

converting SQL money to Double variable chopes of zeros  c#

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 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