|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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
%>
|
|
#2
|
||||
|
||||
|
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 %> |
|
#3
|
|||
|
|||
|
unfortunatley its 2 different databases which makes this more difficult..
|
|
#4
|
||||
|
||||
|
Quote:
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
%>
__________________
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 |
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > Database - Recordset - Want to display only rocords that have sub records |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|