B
Ben
I have two 'Do While Not' statements, that are getting information from
the same recordset. If I comment out the first one I can get the results
for the second one, and vice-versa. Why is this happening? Is it because
it's already at the EOF? If so how do I get it back to the BOF for the
2nd 'Do While Not' statement?
'----------------------------------------
'Create an ADO recordset object
Set rs_Report = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the
database
strSQL = "SELECT gender, referral, youthmember, age FROM tblUsers WHERE
base = '" + Replace(chosenBase, "'", "''") + "'"
'Open the recordset with the SQL query
rs_Report.Open strSQL, adoCon
'-----Gets the total number of male and female users
intMale = 0
intFemale = 0
Do While NOT rs_Report.EOF
If rs_Report("gender") = "male" then
intMale = intMale + 1
Else
intFemale = intFemale + 1
End If
rs_Report.MoveNext()
Loop
'-----Figures out how they heard about the program
Do While NOT rs_Report.EOF
If rs_Report("referral") = "Base Paper" then
intBasePaper = intBasePaper + 1
End IF
rs_Report.MoveNext()
Loop
----------------------------------------------
--Sample Output--
Male = 11
Female = 4
Base Paper =__ "nothing is returned here"
----------------------------------------------
Like I said before If I comment out the first do while not statement I
can get the answers for the second one. If I don't it doesn't even get
inside of the second do while not statement.
I know I can fix it by just having a seperate SQL statement to the
database and get my information seperately, but it seems like a waste of
time. Thanks for any help.
-=Ben
-=To email me take out the joke.
the same recordset. If I comment out the first one I can get the results
for the second one, and vice-versa. Why is this happening? Is it because
it's already at the EOF? If so how do I get it back to the BOF for the
2nd 'Do While Not' statement?
'----------------------------------------
'Create an ADO recordset object
Set rs_Report = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the
database
strSQL = "SELECT gender, referral, youthmember, age FROM tblUsers WHERE
base = '" + Replace(chosenBase, "'", "''") + "'"
'Open the recordset with the SQL query
rs_Report.Open strSQL, adoCon
'-----Gets the total number of male and female users
intMale = 0
intFemale = 0
Do While NOT rs_Report.EOF
If rs_Report("gender") = "male" then
intMale = intMale + 1
Else
intFemale = intFemale + 1
End If
rs_Report.MoveNext()
Loop
'-----Figures out how they heard about the program
Do While NOT rs_Report.EOF
If rs_Report("referral") = "Base Paper" then
intBasePaper = intBasePaper + 1
End IF
rs_Report.MoveNext()
Loop
----------------------------------------------
--Sample Output--
Male = 11
Female = 4
Base Paper =__ "nothing is returned here"
----------------------------------------------
Like I said before If I comment out the first do while not statement I
can get the answers for the second one. If I don't it doesn't even get
inside of the second do while not statement.
I know I can fix it by just having a seperate SQL statement to the
database and get my information seperately, but it seems like a waste of
time. Thanks for any help.
-=Ben
-=To email me take out the joke.