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!

Search the Database with asp

Status
Not open for further replies.

Beracosta

Programmer
Oct 25, 2000
47
0
0
SE
Hi everybody! I want to have a search function on my page. The user types whatever he/she wants to find in a text box and the hits the button. I've tried everything to make this work and i thought that this would work:

"SELECT * FROM Varor WHERE KortBeskrivning LIKE '" & strSearch & "'"

but it doesn't... any ideas?

/Björn
 
Put an asterix on the front / end of the variable, depending on how you want the search to work:
asterix at the front will search for any record where the field ends with the string held in the variable;
asterix at the end will search for any records where the field begins with the string held in the variable;
asterix at the front and at the end will search for records where the field contains the string held in the variable.

"SELECT * FROM Varor WHERE KortBeskrivning LIKE '*" & strSearch & "*'"
Simon
 
it dosen't work.it just doesnä't display any thing!

pls help!
 
There must be something else wrong with your code, then, because the statement I previously posted works. Can you post the rest of your code??
Simon
 
should i'll post the whole search page? it isn't so much code...
 
i think i solved it now. i haven't tried it yet but i think i should use % instead of *....
 
My syntax was for Access - if you are using SQL Server 7, then you should use % instead of * - good old Microsoft!!!
Simon
 
swilliams -

The percent sign as used for a wildcard character is part of the SQL standard. MSAccess uses the asterisk, which is non-standard behavior.

Chip H.
 
What I meant is that we get used to one way of doing things and the same vendor goes and changes it.... At least there seems to be a valid reson for changing things this time, though.
Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top