Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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!
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 Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 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