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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search engine returns 1

Status
Not open for further replies.

tradewise

Programmer
Feb 11, 2003
10
GB
I have created a keyword search and it works ... to a certain degree.

Let me explain. If I want to search for a particular record e.g. 27 I enter 27 in the search text field and press the button. I expect to see record 27 returned.

What happens is that record 27 is returned .... along with 270, 271, 272 etc. It appears to be working as a wildcard of sorts. Is there something that I can do to force a return of exactly what I enter in the search text field?

 
show us your query...

are you using LIKE operator in your search, if yes then change it to "="

-DNG
 
Thanks for your speedy response.

Here's the query ...

strSQL = "SELECT *"
strSQL = strSQL & " FROM tblsyse"
strSQL = strSQL & " WHERE ReferenceNumber like "& "'%" & Request.Form("senum") & "%'"
strSQL = strSQL & " ORDER BY tblsyse.ReferenceNumber;
 
try this:

Code:
strSQL = "SELECT * "
strSQL = strSQL & "FROM tblsyse "
strSQL = strSQL & "WHERE ReferenceNumber = '"&Request.Form("senum")&"' "
strSQL = strSQL & "ORDER BY tblsyse.ReferenceNumber;"

-DNG
 
Tried yours - got data mismatch

took single quotes out as its not a string

code used as follows:

strSQL = "SELECT * "
strSQL = strSQL & "FROM tblsyse "
strSQL = strSQL & "WHERE ReferenceNumber=" & Request.Form("senum") & " "
strSQL = strSQL & "ORDER BY tblsyse.ReferenceNumber;"

thanks for your input
 
The query you posted should work without any problems...BUT I KNOW WHY IT IS NOT WORKING...

it is because your form variable is empty... make sure it is getting populated right...

to see that do a response.write strSQL after your query...

-DNG
 
Sorry

the code that I last posted works a treat

strSQL = "SELECT * "
strSQL = strSQL & "FROM tblsyse "
strSQL = strSQL & "WHERE ReferenceNumber=" & Request.Form("senum") & " "
strSQL = strSQL & "ORDER BY tblsyse.ReferenceNumber;"

thanks again for your input

'til the next time ...........
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top