Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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