473,569 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble converting smallmoney to decimal

Good morning everyone,

I'm having problems when I convert the SQL Server datatype smallmoney to
the .net datatype decimal. I am doing this to pass a dollor amount to
the Verisign payment gateway. Verisign requires that the amount passed
in is in the format ###.##, so if I have 250.50 its passed in exactly as
that. What is happening is that when I use 250.50 the decimal datatype
drops the last zero making this 250.5 which causes the gateway to return
an error stating that I used an incorrect amount. Does anyone have an
idea how I might fix this?

Thanks,

Aaron
Apr 6 '06 #1
1 3766
In numerical terms, the numbers 250.50 and 250.5 are exactly the same. What
you're talking about is the strings "250.50" and "250.5". A number isn't
formatted; a string is. What you're apparently sending to Verisign is a
string, not a number. So, you can format the string using a formatting
string - "###.00".

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Aaron Prohaska" <mo******@gmail .com_No_Spam> wrote in message
news:ej******** ******@TK2MSFTN GP04.phx.gbl...
Good morning everyone,

I'm having problems when I convert the SQL Server datatype smallmoney to
the .net datatype decimal. I am doing this to pass a dollor amount to the
Verisign payment gateway. Verisign requires that the amount passed in is
in the format ###.##, so if I have 250.50 its passed in exactly as that.
What is happening is that when I use 250.50 the decimal datatype drops the
last zero making this 250.5 which causes the gateway to return an error
stating that I used an incorrect amount. Does anyone have an idea how I
might fix this?

Thanks,

Aaron

Apr 6 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3183
by: Newbee Adam | last post by:
I have been reading in help how I need to use decimal becuase currency does not exist like I used in vb6. I had a difficult time on google and msdn finding how or if I can take the value of text box as decimal or do I just have to make another decimal variable .. So I took a guess hoping CDec would come up blue if I type it in with no...
7
4585
by: Paul K | last post by:
I'm writing a small component that needs to be as fast as possible. The component needs to convert a string to decimal during the course of it's processing. However, I need to test the string first to make sure it is numeric. Using the is keyword doesn't work (strings cannot be cast as decimal so false is always returned) and catching an...
1
9964
by: mdawoodk | last post by:
i am getting error "input string was not in correct format" when converting a string decimal into integer value. code is like this: string strVal = ""; int nVal = 0; strVal = "14.9"; nVal += Convert.toInt32(strVal);
3
2147
by: Espen | last post by:
Code: <SCRIPT language="JavaScript"> Rente = "5,9"; Rente2 = parseFloat(Rente.replace(",",".")/100); document.write(Rente2 + '<br>'); Rente = "4,9";
116
35736
by: Dilip | last post by:
Recently in our code, I ran into a situation where were stuffing a float inside a double. The precision was extended automatically because of that. To make a long story short, this caused problems elsewhere in another part of the system where that figure was used for some calculation and some eventual truncation led to the system going...
4
3906
by: tshad | last post by:
I am trying to get some information from Sql Server 2000 in my VS 2003 C# code. For example: if(dbReader != DBNull.Value) wsFilingStatus = (SqlMoney)dbReader; This gives me an error that SqlMoney is not a valid type. But in some of the docs it says this is the one to use. I can't seem to make it work so I
10
1973
by: Ron | last post by:
I want to calculate the surface area of a sphere from an inputed radius with option strict on. I guess I am not converting something correctly. Here is what I am doing: I have a textbox txtradius that I enter a radius into. I then have a lable that I want the surface area to be displayed in called lblsurface
4
3448
by: Jeff | last post by:
Hey ..NET 2.0 In my code am I trying to convert an int value into a decimal: decimal d = 0; int k = 87664; d = Convert.ToDecimal(k/100);
2
5086
by: clintonb | last post by:
Victor said: The double value that I'm trying to convert to GCSMoney (which is implemented as cents) was produced by multiplying a dollar amount by an interest rate to get interest. double amount = 126.60; double interestRate = .075; double interest = amount * interestRate;
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.