DeveloperBarn Forums

Go Back   DeveloperBarn Forums > Programming & Scripting > ASP Development

Discuss "Help with If contains then" in the ASP Development forum.

ASP Development - Learn coding practices and tips to get the best out of your Active Server Pages (ASP). The Classic ASP forum is for ASP/VBScript and ASP/JScript applications.


Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-02-2008, 11:09 AM
Rebelle's Avatar
Contributing Member
 
Join Date: Mar 2008
Posts: 102
Thanks: 15
Thanked 0 Times in 0 Posts
Rep Power: 1
Rebelle is on a distinguished road
Default Help with If contains then

Hi All,

I have a sql view where i pull all records the contains the word ready or repair.

I currently have them ordered by region and this is all good but i would like to have it look like so when it comes to separating by ones containing ready and repair:

Region
---Ready
-------(GC-ready)---tool---currcc
-------(GC-ready)---tool---currcc
-------(DU-ready)---tool---currcc
---Repair
-------(GC-repair)---tool---currcc
-------(AB-repair)---tool---currcc
Next Region
ETC.

Code:
<TR>
<TD bgcolor=#ffe4e1 align=right><%=rs("Loc")%> &nbsp;</TD>
<TD align=center><%=rs("Tools")%> &nbsp;</TD>
<TD align=center><%=rs("CurrCC")%> &nbsp;</TD>
</TR>
Sponsored Links
  #2 (permalink)  
Old 05-02-2008, 11:25 AM
mehere's Avatar
Mistress of Sarcasm

 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 75
Thanks: 5
Thanked 11 Times in 9 Posts
Rep Power: 1
mehere is on a distinguished road
Default

well ... this would all depend on how the data is in the database to see if it can be ordered that way ... so that it can be displayed. otherwise you may have to put the recordset into an array then look at using a disconnected recordset to order it. we really need more information on your table layout along with the data that is currently in the column where you're getting "ready" & "repair"
__________________
Quote of the Month:
Strife: As long as we have each other, we'll never run out of problems.

Questions to Ponder:
I went to a bookstore and asked the saleswoman where the self-help section was and she said if she told me, it would defeat the purpose.

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright © 2008 sbenj69
  #3 (permalink)  
Old 05-02-2008, 12:02 PM
Rebelle's Avatar
Contributing Member
 
Join Date: Mar 2008
Posts: 102
Thanks: 15
Thanked 0 Times in 0 Posts
Rep Power: 1
Rebelle is on a distinguished road
Default

Thanks for the reply Mehere!

Here is the view i'm using:
Code:
SELECT     dbo.tblEQStatus.RegionID, dbo.tblEQStatus.ToolID, dbo.tblEQStatus.DistrictID, dbo.tblEQStatus.EQStatus, dbo.tblEQStatus.TrackingStatus, 
                      dbo.tblEQStatus.EQNumber, dbo.tblEQStatus.Loc, dbo.tblEQStatus.CurrCC, dbo.tblTools.Tools, dbo.tblRegion.RegionName, 
                      dbo.tblDistricts.District_Location
FROM         dbo.tblTools RIGHT OUTER JOIN
                      dbo.tblEQStatus INNER JOIN
                      dbo.tblDistricts INNER JOIN
                      dbo.tblRegion ON dbo.tblDistricts.RegionID = dbo.tblRegion.RegionID ON dbo.tblEQStatus.DistrictID = dbo.tblDistricts.DistrictID ON 
                      dbo.tblTools.ToolID = dbo.tblEQStatus.ToolID
WHERE     (dbo.tblEQStatus.Loc LIKE '%ready%') OR
                      (dbo.tblEQStatus.Loc LIKE '%repair%')
Right now on my results.asp page, I have something like this:
Region
---AB-Repair--Tools---EQNumber
---AB-Repair--Tools---EQNumber
---AB-Ready--Tools---EQNumber
---DU-Repair--Tools---EQNumber
---EH-Ready--Tools---EQNumber
Next Region
Etc.

The LOC field contains hyphens (AB-Repair)

I didn't know if there was a way to use an if statement with code below to say if LOC contains ready then show all the ready, then if repair show all the repair.

Code:
<TR>
<TD bgcolor=#ffe4e1 align=right><%=rs("Loc")%> &nbsp;</TD>
<TD align=center><%=rs("Tools")%> &nbsp;</TD>
<TD align=center><%=rs("CurrCC")%> &nbsp;</TD>
</TR>
  #4 (permalink)  
Old 05-02-2008, 12:08 PM
mehere's Avatar
Mistress of Sarcasm

 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 75
Thanks: 5
Thanked 11 Times in 9 Posts
Rep Power: 1
mehere is on a distinguished road
Default

if you can order it by the LOC field ... then you should be able to do it ... give me a minute to see
  #5 (permalink)  
Old 05-02-2008, 12:16 PM
mehere's Avatar
Mistress of Sarcasm

 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 75
Thanks: 5
Thanked 11 Times in 9 Posts
Rep Power: 1
mehere is on a distinguished road
Default

use an ORDER BY in your statement ... something like this
Code:
ORDER BY dbo.tblEQStatus.RegionID, SUBSTRING(dbo.tblEQStatus.Loc,CHARINDEX('-',dbo.tblEQStatus.Loc)+1,LEN(dbo.tblEQStatus.Loc))
this way all your "Ready" will be together, then all of your "Repair" in each region. Then it should display correctly.

Comments on this post
jmurrayhead agrees: indeed
The Following User Says Thank You to mehere For This Useful Post:
Rebelle (06-17-2008)
  #6 (permalink)  
Old 05-02-2008, 12:57 PM
Rebelle's Avatar
Contributing Member
 
Join Date: Mar 2008
Posts: 102
Thanks: 15
Thanked 0 Times in 0 Posts
Rep Power: 1
Rebelle is on a distinguished road
Default

Super!! That worked out the ordering situation much better!!!

But how can I slip in the static "Ready" group name with only making it show the ready, then the "Repair"?
  #7 (permalink)  
Old 05-02-2008, 01:02 PM
mehere's Avatar
Mistress of Sarcasm

 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 75
Thanks: 5
Thanked 11 Times in 9 Posts
Rep Power: 1
mehere is on a distinguished road
Default

while displaying the records ... check if it's ready or repair ... kinda like the way you're (i'm assuming) you're doing it for region ... something like this:
Code:
do while not rs.EOF
strLoc = rs("loc")
strType = MID(strLoc,inStr(strLoc,"-")+1,len(strLoc))
if strType <> prevType then
     response.Write(strType & "<br />")
end if
response.Write(the rest of the data)
prevType = strType
rs.MoveNext
loop

Last edited by mehere; 05-02-2008 at 01:13 PM. Reason: forgot a parenthesis
  #8 (permalink)  
Old 05-02-2008, 01:05 PM
Rebelle's Avatar
Contributing Member
 
Join Date: Mar 2008
Posts: 102
Thanks: 15
Thanked 0 Times in 0 Posts
Rep Power: 1
Rebelle is on a distinguished road
Default

Ok, I think the MID thing is what I'm missing, I'll give it a try.

Thank you so much!
  #9 (permalink)  
Old 05-02-2008, 01:14 PM
mehere's Avatar
Mistress of Sarcasm

 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 75
Thanks: 5
Thanked 11 Times in 9 Posts
Rep Power: 1
mehere is on a distinguished road
Default

np ... let me know how it works out for you
  #10 (permalink)  
Old 05-02-2008, 01:31 PM
Rebelle's Avatar
Contributing Member
 
Join Date: Mar 2008
Posts: 102
Thanks: 15
Thanked 0 Times in 0 Posts
Rep Power: 1
Rebelle is on a distinguished road
Default

Any clue why it doesn't like the MID?, getting the following.

Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Mid'
Closed Thread

  DeveloperBarn Forums > Programming & Scripting > ASP Development

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Sponsored Links

ASP.NET Resource Index
a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer.

Free Web Directory
Including Chats and Forums Resources, Offer automatic, instant and free directory submissions.
URLZ Web Directory
URLZ Web Directory

Free Web Directory - Add Your Link
The Little Web Directory
Free Web Directory
Pegasus free web directory is a free directory organised by categories.


All times are GMT -4. The time now is 01:06 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC7
©2008 DeveloperBarn.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45