Search with NUD

thirteentwenty

Well-known member
Joined
Oct 9, 2008
Messages
80
Location
Honolulu
Programming Experience
Beginner
I've created a small search form and all works well except one item... searching by a number, more specifically by a dollar amount. the problem lies with the last digit, if it is a 0 the search will fail to get the results. I was just goint to force the format and recalled JuggaloBrothas post on the NUD, after getting the NUD setup properly (I think) same game, if the query has a trailing 0 it will not complete the search. I've tried appending a wildcard to the end of the search string but still no dice. Any ideas?
 
Last edited:
What you can do is assign the value of the queries parameter as a string, which means you can take the NUD value, convert it to a string and strip off all of the zeros at the end of the string.
 
Why? "Search query has the dumb"?

HAHAHA my bad, what I meant was that if the query ends in 0 it will fail to post any results.


JuggaloBrotha said:
What you can do is assign the value of the queries parameter as a string, which means you can take the NUD value, convert it to a string and strip off all of the zeros at the end of the string.

If I convert it to string (dim i as string = nud.text) would that work to pickup the last zero?
 
right now if i wanted to search for something like 333.30 it removes the trailing 0 and searches for 333.3 and no results are given. What I'm asking is if I convert it to string would it keep the trailing 0?

sorry if i dont make any sense right now just got to work and the coffee machine is borked =(
 
We know what the problem is already, but you haven't posted the query, the sql that's not working when there's a trailing zero. A trailing zero when it comes to number matching isn't normally a problem, so there's probably something going on with how the queries built that is a problem.
 
Ahh my mistake

VB.NET:
"SELECT * FROM [Transaction Items] WHERE [Grand Total] LIKE & '" frm_search.nud_search_total.text & "%'""

and I've actually got it working but I'm not sure if it's proper or just a duct tape solution

What I've done is

VB.NET:
Dim total as String = frm_search.nud_search_total.value
 
I'd suggest that you:

Sort out in your mind and your database, whether this is a number, or a string, and then make it consistently a number or a string all the way through

If it's supposed to be a number, make the DB column a number, make the query select using numerical operators (=, >, < ), make the parameter to the query a number, and put a number in it!

Shoeing everything to/from string several times is the root cause of all these problems.. You must take a more strict approach to your datatypes!
 

Latest posts

Back
Top