Solved

What c# variable type do I use to work with SQL money data types?

Posted on 2007-04-06
4
433 Views
Last Modified: 2008-02-01
What c# variable type do I use to work with SQL money data types?

If I am pulling a "money" data type out of a sql query and need to set that value to a variable to work with it in c# what is teh proper variable type..how do you covert it?
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 10

Assisted Solution

by:Si_Hibbard
Si_Hibbard earned 200 total points
ID: 18864015
I use decimal and then format the output when displaying using {c,"0"}
0
 
LVL 10

Expert Comment

by:Si_Hibbard
ID: 18864021
oops mistyped the format shoud be "{0:c}"
0
 
LVL 15

Accepted Solution

by:
dave4dl earned 300 total points
ID: 18865141
Csharp data types:
http://www.samspublishing.com/articles/article.asp?p=101656&seqNum=2&rl=1

sql server 2000 data types:
http://www.databasejournal.com/features/mssql/article.phpr/2212141

Since double and money are both eight byte numbers double should work (though they do appear to have slightly different encoding).  The csharp "decimal" data type is 12 bytes long so it is almost certain to be capable of representing any money value.
0
 
LVL 15

Expert Comment

by:dave4dl
ID: 18865171
Woops, clicked submit too quickly.
I wanted to add that if you use the double type versus the decimal your code will be more efficient even though they will both work.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

626 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