Solved

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

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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!
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

26 Experts available now in Live!

Get 1:1 Help Now