|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need help adding a wildcard statement!
Hi guys,
I have some code that generates a dropdown select box populated by Product Category names from my storefront system. Problem is, i want to filter it to show only a few specific categories. In the following instance, I would like to insert the wildcard statement " IS LIKE 'IMAGE%' " into the SQL select. The problem is, with all the other statements involved in the select, i can't figure out where to put the wildcard filter. Here is the code in question: __________ Sub ShowImgGroups(ParentGroup, parentCount, commaDelimit, style) Dim rsIMAGE, theDescrip, Indent, ttl2, rsCount, count, showIMG Set rsIMAGE = cnDZ.Execute("SELECT * FROM qGroupsParents WHERE ParentID "&_ IIF(IsNull(ParentGroup), "IS NULL", "= "&ParentGroup)&" ORDER BY Name ASC;") __________ I've tried various combinations which i thought we're logical such as putting & IS LIKE "IMAGE%" after "IS NULL" but nothing works! Help! In this case i want to filter my product categories to only show names starting with "Image". To see it in action, go to URL . The dropdown box in the top middle currently displays all my product categories; I would like it to only display categories related to each page, i.e., I dont want to display Font or Templates categories on the Image page. Thanks! |
|
#2
|
||||
|
||||
|
Code:
SELECT * FROM qGroupsParents WHERE ParentID "&_ IIF(IsNull(ParentGroup), "IS NULL", "= "&ParentGroup)&" AND categories LIKE 'Image%' ORDER BY Name ASC;") You may need to replace the % with an *. |
|
#3
|
|||
|
|||
|
Almost..
hi Memnoch,
Thanks.. that looks like the answer i'm looking for. However, it generates the following error: Microsoft VBScript compilation error '800a0409' Unterminated string constant /inx/global.inc, line 579 IIF(IsNull(ParentGroup), "IS NULL", "= "&ParentGroup)&"-------------------------------------------------------^Any ideas? Thanks, Keith Last edited by flyerstarter : April 6th, 2004 at 11:05 AM. |
|
#4
|
||||
|
||||
|
you shouldn't need the IIF statement. Try this
Code:
SELECT * FROM qGroupsParents WHERE ParentID = " & ParentGroup & " AND categories LIKE 'Image%' ORDER BY Name ASC;") |
|
#5
|
|||
|
|||
|
Not yet
Hi Menmoch,
Sorry, that generated an error as well. I will post the whole sub in context. It's a bit convulated as it is designed to toggle from a selectbox-dropdown display of the product categories to a text-based listing. On this note, one other thing about this bit of code thats bugging me is that I noticed on Mac-IE only for some reason this code displays both the dropdown box AND the text listings underneath, which is very no good for the general page layout. I thought i solved the problem by eliminating some code later on in the sub, but now it just displays blank placeholders for the text listings, which is almost worse. Any ideas why there would be a difference between mac and pc in this code? Here is the whole sub: ______ Sub ShowImgGroups(ParentGroup, parentCount, commaDelimit, style) Dim rsIMAGE, theDescrip, Indent, ttl2, rsCount, count, showIMG Set rsIMAGE = cnDZ.Execute("SELECT * FROM qGroupsParents WHERE ParentID "&_ IIF(IsNull(ParentGroup), "IS NULL", "= "&ParentGroup)&" ORDER BY Name ASC;") If Not rsIMAGE.EOF Then count = 0 If parentCount = 0 And style = True Then Response.Write"<form action=""http://"&homepage_url&"/default.asp"" method=get> <input type=hidden name=pg value=products>"&_ "<select name=grp>" End If Do Until rsIMAGE.EOF If IsNull(rsIMAGE("IMG")) Or Trim("X"&rsIMAGE("IMG")) = "X" Then showIMG = "" Else showIMG = "<img src=""img/"&rsIMAGE("IMG")&""" border=0>" thedescrip = rsIMAGE ("DESCRIP") Indent = Replace(Space(parentCount), " ", " ") If Trim("X"&thedescrip) <> "X" Then ttl2 = " title="""&thedescrip&"""" If commaDelimit = True Then If count > 0 Then Response.Write ", " Else If parentCount <> 0 Or count > 0 Then Response.Write"<br>" Response.Write Indent End If If parentCount = 0 Then If style = False Then Response.Write"<a href=""<A href="http://"&homepage_url&"/default.asp?pg=products&grp="&rsIMAGE">http://"&homepage_url&"/default.asp?pg=products&grp="&rsIMAGE ("GROUPID")&""""&ttl2&">"&showIMG&"<b style=""letter-spacing:1px"">"&rsIMAGE ("NAME")&"</b></a>" Else Response.Write"<option value=" & rsIMAGE("GroupID") & ">" & rsIMAGE("Name") & "</option>" End If Else If style = True Then Response.Write"<option value=" & rsIMAGE("GroupID") & ">" If parentCount > 1 Then Response.Write" " If commaDelimit = False And style = False Then Response.Write"<a href=""<A href="http://"&homepage_url&"/default.asp?pg=products&grp="&rsIMAGE">http://"&homepage_url&"/default.asp?pg=products&grp="&rsIMAGE ("GROUPID")&""""&ttl2&"><img src=""img/indent-dots.gif"" width=10 height=1 align=absmiddle border=0> "&showIMG&""&rsIMAGE("NAME")&"</a>" ElseIf style = False Then Response.Write" <a href=""<A href="http://"&homepage_url&"/default.asp?pg=products&grp="&rsIMAGE">http://"&homepage_url&"/default.asp?pg=products&grp="&rsIMAGE ("GROUPID")&""""&ttl2&">"&showIMG&""&rsIMAGE("NAME")&"</a>" Else Response.Write" " & rsIMAGE("NAME") End If If style = True Then Response.Write "</option>" End If ShowGroups rsIMAGE("GROUPID"), parentCount + 1, commaDelimit, style count = count + 1 rsIMAGE.MoveNext CheckConnection Loop If parentCount = 0 And style = True Then Response.Write"</select> <input type=""IMAGE"" SRC=""/img/go.gif"" ALT=""Submit button"" BORDER=""0""></form>" End If rsIMAGE.Close Set rsIMAGE = Nothing End Sub ______ Thanks! |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Need help adding a wildcard statement! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|