Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validate money data type

Status
Not open for further replies.

JoeZim

MIS
Sep 11, 2003
87
US
I have many update fields in my application to update SQL Server data type money. I am currently using the following compare validation on each field:

Code:
<asp:CompareValidator ID="vUWIncome" runat="server" ControlToValidate="txtUWIncome"
ErrorMessage="CompareValidator" Operator="DataTypeCheck" Type="Double" Width="232px">Please enter numeric value!</asp:CompareValidator>

Problem I'm having is when a user keys in a value greater than 922,337,203,685,477.5807, this validation does not catch it and I get the 'Error converting data type nvarchar to money'.

What is the best type of validation control to handle this?

Thanks
 
Would you need to enter values greater then that? You can limit your textbox in max characters allowed to take care of that.

Or you could add code to test the value from this field before you insert it into your sql table.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- The Complete IT Community
 
No, but if someone happens to do so, I'd like to catch it. I am going to use your suggestion of max characters allowed, which should work.

Is there a recommended type of validation control for the money data type that also prevents this from happening?
 
922 trillion dollars?
Do you work for the government? of Dubai?

I think there is a CompareValidator DataType of "Currency" available. Im not sure if it will handle more than 2 decimal places though. (not sure of your format requirements)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top