SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 6th, 2004, 10:31 AM
flyerstarter flyerstarter is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 flyerstarter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!

Reply With Quote
  #2  
Old April 6th, 2004, 10:51 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
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 *.

Reply With Quote
  #3  
Old April 6th, 2004, 10:56 AM
flyerstarter flyerstarter is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 flyerstarter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old April 6th, 2004, 11:07 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
you shouldn't need the IIF statement. Try this
Code:
SELECT * FROM qGroupsParents WHERE ParentID = " & ParentGroup & "
AND categories LIKE 'Image%' ORDER BY Name ASC;")

Reply With Quote
  #5  
Old April 6th, 2004, 11:19 AM
flyerstarter flyerstarter is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 flyerstarter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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), " ", "&nbsp;")
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"&nbsp;&nbsp;"
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>&nbsp;"&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"&nbsp;&nbsp;" & 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!

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Need help adding a wildcard statement!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT