Solved

converting SQL money to Double variable chopes of zeros  c#

Posted on 2007-04-06
4
1,002 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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