Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

821 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