[thelist] sql filtering problem

darren darren at web-bitch.co.uk
Tue Aug 27 10:23:01 CDT 2002


On Tuesday, August 27, 2002 at 15:55, dn at dittodesign.co.uk wrote:

ddcu> is the result of choices made over two pages each containing
ddcu> a drop box. So case is not an issue.

ddcu> I need to filter the result page by the two variables in the url.

how about something like:

   dim brand, productType, strSQL, objCon, objRc

   brand = Request.QueryString("Brand")
   productType = Request.QueryString("Product_Type")

   ' you might want to response.write these to make sure they have the
   ' correct values

   strSQL = "SELECT Brand_Logo, Brand_Logo_sml, ID, Product_Type, Brand, " & _
            "Model, Reference_No, Colour, image, Retail_Price, " & _
            "Delivery_Charge FROM kitchen_appliance WHERE 1 = 1"

   if len(brand) > 0 then strSQL = strSQL & " brand = '" & brand & "'"
   if len(productType) > 0 then strSQL = strSQL & " Product_Type = '" &
   productType & "'"

   set objCon = Server.CreateObject("ADODB.Connection")
   set objRc = Server.CreateObject("ADODB.Recordset")
   objCon.Open yourConnectionString
   objRc.CursorLocation = adUseServer
   objRc.Open strSQL, objCon, adOpenForwardOnly, , adCmdText

   if (objRc.BOF and objRc.EOF) then
      ' you have no records
   else
      ' process your result set
   end if

   objRc.Close
   objCon.Close
   set objRc = nothing
   set objCon = nothing

hth,

darren




More information about the thelist mailing list