Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 comma problem

Author  Topic 

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-06-07 : 19:13:34
As we know if database field is currency, when we are inserting SQL database, if we entered comma instead of period, it will cause problem. If I use replace function to replace comma with nothing than number can get really big and user wouldn't know the difference. For this can I create a some sort of validation code the alert the user, comma entered? How can I do that? Any idea? I use vb.net

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-06-07 : 19:24:13
Do this in your VB.NET code and not inside SQL Server.

Tara
Go to Top of Page

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-06-07 : 19:37:11
yes that's I am going to do, but any idea what kind of code I should use?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-06-07 : 19:39:01
Sorry! Didn't notice this was in the ASP.NET forum. Please ignore me.

Tara
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-06-07 : 19:39:28
The String object has a Replace method, that would be a good start.
Go to Top of Page

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-06-07 : 19:46:26
like I said, I think it is not that good for me to use replace function and if user enters comma accidentally, my function will catch that and replace it with nothing. I don't want that. Can I write a code that if user enters comma in a textbox along with numbers and wants to save that, it will alert user?
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-06-07 : 20:03:41
Sorry, my mistake.

You can use a Validator control to check for a comma and provide a message for the user. You can also have it validate the number's format according to the decimal character you want to use.
Go to Top of Page

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-06-07 : 20:09:16
I like that idea "You can use a Validator control to check for a comma and provide a message for the user." So, how can I set this up please?
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-06-07 : 20:19:50
Best thing to do is read up on them in the .Net documentation. If you don't find a good example there, then try here:

http://aspnet.4guysfromrolla.com/
Go to Top of Page

jhermiz

3564 Posts

Posted - 2005-06-07 : 22:16:05
Dont forget that vb.net does not support the currency type. You will need to use Int64 and/or CDec() to get the correct values. You may also use regular expressions to ensure that only specific data is entered into the text box.
A validator control can be used to validate the input and one of the properties is ErrorMessage (IIRC) to display what text if an error occurs.




Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]
Imperfection living for perfection --
[url]http://jhermiz.blogspot.com/[/url]
Go to Top of Page
   

- Advertisement -