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

Simple ASP search facility

Status
Not open for further replies.

enzobanzai

Technical User
Jun 24, 2004
16
AU
Hi

I am new to all this so I need a little help.

My client wants a litttle search facility in his site.

I am doing this in ASP VB with Access as the DB.

Heres the search page:

Now the table in my database (tbl_stock) is a simple one that just contains the following corresponding fields.

txtName
txtSupplierCode
intDimension
intGSM
intCategory

Does anybody know of the SQL code I can use to return a result on my next search_results.aap page.

At the moment I am drawing blanks :(

I know that you have to set up variables like request.QueryString("name") and then use LIKE and = but I cant get it to work?

any ideas??

Dave
 
Code:
<%
  'db_connection code

name = Request("name")
code = Request("code")
dimension = Request("dimension")
gsm = Request("gsm")
cat = Request("cat")

' you could use like but i don't know what data is being
' pulled to have to put in a like, so use for example  
' purposes only


' this is on-the-fly so you want to make sure that there 
' are "spaces in between the concat & _ and the AND
' it may cause syntax error...someone else may point it
' out...i used it to make it easier to read

strSQL="SELECT txtName, txtSupplierCode, intDimension, intGSM, intCategory " & _
       "FROM tbl_stock " & _
       "WHERE intCategory=" & cat & " & _
       "AND txtName LIKE '" & name & "%' " & _
       "AND txtSupplierCode LIKE '" & code & "%' " & _
       "AND intDimension=" & dimension & " & _
       "AND intGSM=" & gsm & ";"

objRS.Open strSQL, objConn

    If objRS.EOF Then 
         Response.Write "No records found"
    Else
    
      Do While Not objRS.EOF

      ' create a table and enter objRS("dbfield")

       objRS.MoveNext
       Loop
    End If
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top