ASP .NET: SQL Server Money Type and .NET Currency Type

Posted by Rudi Ramey on Stack Overflow See other posts from Stack Overflow or by Rudi Ramey
Published on 2010-04-21T01:23:59Z Indexed on 2010/04/21 1:33 UTC
Read the original article Hit count: 568

MS SQL Server's Money Data Type seems to accept a well formatted currency value with no problem (example: $52,334.50) From my research MS SQL Sever just ignores the "$" and "," characters. ASP .NET has a parameter object that has a Type/DbType property and Currency is an available option to set as a value. However, when I set the parameter Type or DbType to currency it will not accept a value like $52,334.50. I receive an error "Input string was not in a correct format." when I try to Update/Insert. If I don't include the "$" or "," characters it seems to work fine. Also, if I don't specify the Type or DbType for the parameter it seems to work fine also. Is this just standard behavior that the parameter object with its Type set to currency will still reject "$" and "," characters in ASP .NET?

Here's an example of the parameter declaration (in the .aspx page):

<asp:Parameter Name="ImplementCost" DbType="Currency" />

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about parameters