Trouble converting smallmoney to decimal

  • Thread starter Thread starter Aaron Prohaska
  • Start date Start date
A

Aaron Prohaska

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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top