theflyingminst
02-06-2009, 01:54 AM
Hi, I've nested a loop to write out all comments corresponding to it's original message (RS & RSs). The loop works perfectly fine for the first record in "RS" but will not display for the rest of the records.
<%
Set adoCon = Server.CreateObject("ADODB.Connection")
strCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &Server.MapPath("data.mdb")
adoCon.Open strCon
Set RS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM MESSAGES ORDER BY ID Desc"
RS.Open strSQL, adoCon
uniquen = RS("uniquen")
Set RSs = Server.CreateObject("ADODB.Recordset")
strSQL2 = "SELECT * FROM COMMENTS WHERE uniquen LIKE '%" & uniquen & "%' ORDER BY ID Desc"
RSs.Open strSQL2, adoCon
Do While Not RS.EOF
response.write "-----------<br>"
response.write RS("message")
response.write "<br>"
Do While Not RSs.EOF
response.write RSs("comments")
response.write "<br>"
RSs.MoveNext
Loop
response.write "<br>-----------"
RS.MoveNext
Loop
Set RS = Nothing
Set RSs = Nothing
adoCon.Close
Set adoCon = Nothing
%>
Any help is greatly appreciated.
Thank you
<%
Set adoCon = Server.CreateObject("ADODB.Connection")
strCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &Server.MapPath("data.mdb")
adoCon.Open strCon
Set RS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM MESSAGES ORDER BY ID Desc"
RS.Open strSQL, adoCon
uniquen = RS("uniquen")
Set RSs = Server.CreateObject("ADODB.Recordset")
strSQL2 = "SELECT * FROM COMMENTS WHERE uniquen LIKE '%" & uniquen & "%' ORDER BY ID Desc"
RSs.Open strSQL2, adoCon
Do While Not RS.EOF
response.write "-----------<br>"
response.write RS("message")
response.write "<br>"
Do While Not RSs.EOF
response.write RSs("comments")
response.write "<br>"
RSs.MoveNext
Loop
response.write "<br>-----------"
RS.MoveNext
Loop
Set RS = Nothing
Set RSs = Nothing
adoCon.Close
Set adoCon = Nothing
%>
Any help is greatly appreciated.
Thank you