Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I am very impressed with the site and have already recommended it to one of my associates. I was truly impressed with the quickness in which someone actually responded to my question..."

Geography

Where in the world do Tek-Tips members come from?
pinkpoppy (Programmer)
23 May 12 12:40
Hi there,
I have a search function on my web site and am trying to figure why this code does not work. The search function needs to accept numbers 0 to 9, letters a to z, cap letters A to Z, spaces, no spaces, and dashes. Right now the function accepts all but am having problems with search term that contains numbers and letters.

For example, one of the search term in the database is: W12-543-TR-G5-2001

So when a user searches for that particular data, entering "W12-543-TR-G5-2001" or "W12543TRG52001" should render the results. My current codes is not accepting these terms.

string searchterm= "";
for (int i = 0; i < _keyword.Length; i++)
{
if ((_keyword[i] >= 'a' && _keyword[i] <= 'z') || (_keyword[i] >= 'A' && _keyword[i] <= 'Z') || (_keyword[i] >= '0' && _keyword[i] <= '9') || _keyword[i] == ' ' || _keyword[i] == '-')
{
searchterm+= _keyword[i];
}
}
_keyword = searchterm;

Any help or suggestions is greatly appreciated!
jbenson001 (Programmer)
23 May 12 13:10
Searching should be done in the database. You need to determine if there is a set structure for your data, in other words, how it is stored in the db. Then you have to construct your search parameters to search your DB correctly.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close