Question : How to return more the one row with recordset...

I have code that does this:

                                    
for i = 1 to intNbrAtts

sqlSub(i) = "SELECT attendee_name, attendee_email FROM meetings_attendees WHERE meeting_id = '" & intMtgID & "' AND (invited = '0' OR invited IS NULL) AND (emailed = '0' OR emailed IS NULL)"

      'Response.Write(sqlSub(i))
                                          Set objRSAtt = objConn.Execute(sqlSub(i))
                                                strAttName = objRSAtt.Fields.Item("attendee_name").Value
      strAttEmail = objRSAtt.Fields.Item("attendee_email").Value

      objRSAtt.MoveNext

      Response.Write(strAttName) & "<br />"
      Response.Write(strAttEmail) & "<br />"
next

The givens are:

intNbrAtts = n where n can be any number

objRSAtt = Server.CreateObject(ADODB.Recordset)

My result set is:

joe Smith
[email protected]
joe Smith
[email protected]

WHEN it should be:

joe Smith
[email protected]
jane jones
[email protected]

Why am I getting the first row twice?

Peter

Answer : How to return more the one row with recordset...

Because your For...Next loop is not enumerating the rows in the recordset.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
SQL = "SELECT attendee_name, attendee_email " & _
    "FROM meetings_attendees " & _
    "WHERE meeting_id = '" & intMtgID & "' AND (invited = '0' OR invited IS NULL) " & _
    "AND (emailed = '0' OR emailed IS NULL)"
 
Set objRSAtt = objConn.Execute(SQL)
 
Do Until objRSAtt.EOF
    strAttName = objRSAtt.Fields.Item("attendee_name").Value
    strAttEmail = objRSAtt.Fields.Item("attendee_email").Value
    Response.Write(strAttName) & "<br />"
    Response.Write(strAttEmail) & "<br />"
    objRSAtt.MoveNext
Loop
Random Solutions  
 
programming4us programming4us