ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP 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:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 9th, 2008, 10:06 AM
cwfontan cwfontan is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 68 cwfontan User rank is Corporal (100 - 500 Reputation Level)cwfontan User rank is Corporal (100 - 500 Reputation Level)cwfontan User rank is Corporal (100 - 500 Reputation Level)cwfontan User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 18 h 58 m 7 sec
Reputation Power: 2
Database - Recordset - Want to display only rocords that have sub records

this displays all the categories and policies under those categories.. I just want to display the categories that have policies under them. Thanks for any help..

Code:
catRS.Source = "SELECT descript, catValue FROM dbo.category"

do while not catRS.eof
policyRS.Source = "SELECT * FROM dbo.formList WHERE categoryId = '" & catRS("catValue") & "'"

response.write(catRS("descript") & "<br>")
do while not policyRS.eof
response.write(policyRS("formNumber") & "<br>")
policyRS.movenext
loop
catRS.movenext
loop
%>

Reply With Quote
  #2  
Old May 9th, 2008, 10:24 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Contributing User
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,259 sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level)sync_or_swim User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 3 Weeks 2 Days 23 h 8 m 7 sec
Reputation Power: 755
I dont know if this will work but you seem to have a link between the category table and the formList table so you could just join the two tables in one SQL statement and then loop throug the recordset only outputting the title when the description changes:
Code:
'NOT TESTED
catRS.Source = "SELECT c.descript, c.catValue, f.formNumber" & _
"FROM dbo.categoryc, formList f where c.catValue = f.categoryId"

Dim lastVal
lastVal = ""
do while not catRS.eof
	If lastVal <> catRS.Fields(1) Then response.write(catRS.Fields(0) & "<br>")
	response.write(catRS.Fields(2) & "<br>")
	lastVal = catRS.Fields(1)
catRS.movenext
loop
%>

Reply With Quote
  #3  
Old May 12th, 2008, 01:36 PM
cwfontan cwfontan is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 68 cwfontan User rank is Corporal (100 - 500 Reputation Level)cwfontan User rank is Corporal (100 - 500 Reputation Level)cwfontan User rank is Corporal (100 - 500 Reputation Level)cwfontan User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 18 h 58 m 7 sec
Reputation Power: 2
unfortunatley its 2 different databases which makes this more difficult..

Reply With Quote
  #4  
Old May 12th, 2008, 07:47 PM
keep_it_simple's Avatar
keep_it_simple keep_it_simple is offline
KIS
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jul 2007
Location: USA
Posts: 1,031 keep_it_simple User rank is Major (30000 - 40000 Reputation Level)keep_it_simple User rank is Major (30000 - 40000 Reputation Level)keep_it_simple User rank is Major (30000 - 40000 Reputation Level)keep_it_simple User rank is Major (30000 - 40000 Reputation Level)keep_it_simple User rank is Major (30000 - 40000 Reputation Level)keep_it_simple User rank is Major (30000 - 40000 Reputation Level)keep_it_simple User rank is Major (30000 - 40000 Reputation Level)keep_it_simple User rank is Major (30000 - 40000 Reputation Level)keep_it_simple User rank is Major (30000 - 40000 Reputation Level)keep_it_simple User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 2 Days 8 h 12 m 51 sec
Reputation Power: 340
Send a message via Yahoo to keep_it_simple
Quote:
Originally Posted by cwfontan
unfortunatley its 2 different databases which makes this more difficult..



what determines if it has policies/ no form number?...???

modify accordingly...ie;null vs '' or if a true number(formNumber)

Code:
catRS.Source = "SELECT descript, catValue FROM dbo.category"

do while not catRS.eof
policyRS.Source = "SELECT formNumber " & _
                  "FROM dboformList " & _
                  "WHERE categoryId = '" & catRS("catValue") & "' AND " & _
                  "      formNumber <> '';"

 If Not policyRS.EOF Then
  Response.write(catRS("descript") & "<br>")
 
  do while not policyRS.eof
   response.write(policyRS("formNumber") & "<br>")
  policyRS.movenext
  loop

 End If
catRS.movenext
loop
%>
Comments on this post
cwfontan agrees: Great thanks..
__________________
Please give respect to those that helped solve an issue by clicking on the reputation icon

Last edited by keep_it_simple : May 12th, 2008 at 08:01 PM. Reason: removed description...not in 2nd rs

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Database - Recordset - Want to display only rocords that have sub records


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