Hi,
I am having a looping problem. I have a loop that first checks for each clientid and then does a calculations for evey clientid one of these calculations require a loop.
The problem I am having is the first clientid calculations are done correctly but anything after that gives the same results and the calculation that is in the loop only give a result for the first calculation and then gives 0 for all the rest of the clientid.
This the output of my results
1 clientid
0
825
1
20
30
750
390 calaculation that uses loop
12.5
1965 total results
2 clientid
0
825
1
20
30
750
0 calaculation that uses loop
12.5
1575 total
5 clientid
0
825
1
20
30
750
0 calaculation that uses loop
12.5
1575 total
7 clientid
0
825
1
20
30
750
0 calaculation that uses loop
12.5
1575 total
as you can see my results are not changing but the clientid is.
This my code
Do while not oRScp.EOF
StropportunityID = oRScp("opportunityId")
response.write StropportunityID & "<br>"
geography=0
if StrlocationState = PreferredState then
geography = geography + 10
end if
if StrlocationState = StateBirth then
geography = geography + 40
end if
if StrlocationState = medstate then
geography = geography + 60
end if
'response.write geography & "<br>"
'response.end
if StrlocationState = l_states then
geography = geography + 10
end if
geography=geography*30
response.write geography & "<br>"
'response.end
qualifications=0
if medstate="INT" then
qualifications=qualifications+(strIMG*10)
ELSE
qualifications=qualifications+ (strAMG *10)
end if
if C_Status = "Residents" then
qualifications=qualifications(strRESGRAD*5)
end if
if C_Status = "Fellow" then
qualifications=qualifications+(strRESGRAD*5)
end if
if C_Status = "Military" then
qualifications=qualifications+(strPRACHY*5)
end if
if pBoardStatus = BoardStatus then
qualifications=qualifications+ 10
end if
if StrlocationState = l_states then
qualifications=qualifications+ 15
end if
qualifications=qualifications*15
response.write qualifications & "<br>"
'response.end
IF paytype =1 then
p_min=p_min*2080
end if
IF paytype =1 then
p_max=p_max*2080
end if
IF strsalarytype = 1 then
o_min=o_min*2080
END IF
IF strsalarytype = 1 then
o_max=o_max*2080
end if
response.write strsalarytype & "<br>"
'response.write o_min & "<br>"
'response.write o_max & "<br>"
'response.write paytype & "<br>"
'response.write p_min & "<br>"
'response.write p_max & "<br>"
salary=0
salcal=0
salcal=((p_min - o_min)/o_min)*100
'response.write o_min & "<br>"
'response.write p_min & "<br>"
'response.write salcal
if salcal >=0 and salcal <=10 then
salary="100"
elseif salcal >=11 and salcal <=20 then
salary="80"
elseif salcal >=21 and salcal <= 30 then
salary="70"
elseif salcal >=31 and salcal <= 70 then
salary="40"
else salary="20"
end if
response.write salary & "<br>"
'response.end
salary1=0
salcal2=0
salcal2=(p_max - o_max)/o_max *100
'response.write o_max & "<br>"
'response.write p_max & "<br>"
'response.write salcal2
if salcal >=0 and salcal <=10 then
salary1="100"
elseif salcal >=11 and salcal <=20 then
salary1="80"
elseif salcal >=21 and salcal <= 30 then
salary1="60"
elseif salcalsalcal >=31 and salcal <= 40 then
salary1="20"
else salary1=30
end if
response.write salary1 & "<br>"
'response.end
tsalary=CDbl(salary)+CDbl(salary1)
'response.write salary& "<br>"
'response.write salary1& "<br>"
'response.write tsalary& "<br>"
tsalary=CDbl(tsalary)*15
response.write tsalary & "<br>"
'response.end
QUESTIONS=0
DO While not rt.EOF
o_questionid=p_questionid
if O_questionID = P_questionID then
questions=questions+2
else
questions =questions
end if
rt.movenext
loop
QUESTIONS=QUESTIONS*15
response.write questions & "<br>"
'response.end
lifestyle=0
if strclakes = 1 then
lifestyle=lifestyle+(strlakes*2.5)
end if
if strcdine = 2 then
lifestyle=lifestyle+(strdine*2.5)
end if
if strcart = 4 then
lifestyle=lifestyle+(strart*2.5)
end if
if strcairport = 8 then
lifestyle=lifestyle+(strairport*2.5)
end if
lifestyle=lifestyle*15
response.write lifestyle & "<br>"
'response.end
rating=cint(QUESTIONS)+cint(tsalary)+cint(qualifications)+cint(lifestyle)+cint(geography)
RESPONSE.WRITE RATING & "<br>"
txtsql ="INSERT INTO rating (opportunityid,physicianID,rating)values ('" & StropportunityID & "','" & strphysicianid &"', '" & rating & "')"
conn.Execute txtsql
'RESPONSE.End
'rt.Close(how to comment this out for the 2nd loop to work)
'Set rt= nothing
oRScp.movenext
loop
set oRScp = nothing
set conn = nothing
I am having a looping problem. I have a loop that first checks for each clientid and then does a calculations for evey clientid one of these calculations require a loop.
The problem I am having is the first clientid calculations are done correctly but anything after that gives the same results and the calculation that is in the loop only give a result for the first calculation and then gives 0 for all the rest of the clientid.
This the output of my results
1 clientid
0
825
1
20
30
750
390 calaculation that uses loop
12.5
1965 total results
2 clientid
0
825
1
20
30
750
0 calaculation that uses loop
12.5
1575 total
5 clientid
0
825
1
20
30
750
0 calaculation that uses loop
12.5
1575 total
7 clientid
0
825
1
20
30
750
0 calaculation that uses loop
12.5
1575 total
as you can see my results are not changing but the clientid is.
This my code
Do while not oRScp.EOF
StropportunityID = oRScp("opportunityId")
response.write StropportunityID & "<br>"
geography=0
if StrlocationState = PreferredState then
geography = geography + 10
end if
if StrlocationState = StateBirth then
geography = geography + 40
end if
if StrlocationState = medstate then
geography = geography + 60
end if
'response.write geography & "<br>"
'response.end
if StrlocationState = l_states then
geography = geography + 10
end if
geography=geography*30
response.write geography & "<br>"
'response.end
qualifications=0
if medstate="INT" then
qualifications=qualifications+(strIMG*10)
ELSE
qualifications=qualifications+ (strAMG *10)
end if
if C_Status = "Residents" then
qualifications=qualifications(strRESGRAD*5)
end if
if C_Status = "Fellow" then
qualifications=qualifications+(strRESGRAD*5)
end if
if C_Status = "Military" then
qualifications=qualifications+(strPRACHY*5)
end if
if pBoardStatus = BoardStatus then
qualifications=qualifications+ 10
end if
if StrlocationState = l_states then
qualifications=qualifications+ 15
end if
qualifications=qualifications*15
response.write qualifications & "<br>"
'response.end
IF paytype =1 then
p_min=p_min*2080
end if
IF paytype =1 then
p_max=p_max*2080
end if
IF strsalarytype = 1 then
o_min=o_min*2080
END IF
IF strsalarytype = 1 then
o_max=o_max*2080
end if
response.write strsalarytype & "<br>"
'response.write o_min & "<br>"
'response.write o_max & "<br>"
'response.write paytype & "<br>"
'response.write p_min & "<br>"
'response.write p_max & "<br>"
salary=0
salcal=0
salcal=((p_min - o_min)/o_min)*100
'response.write o_min & "<br>"
'response.write p_min & "<br>"
'response.write salcal
if salcal >=0 and salcal <=10 then
salary="100"
elseif salcal >=11 and salcal <=20 then
salary="80"
elseif salcal >=21 and salcal <= 30 then
salary="70"
elseif salcal >=31 and salcal <= 70 then
salary="40"
else salary="20"
end if
response.write salary & "<br>"
'response.end
salary1=0
salcal2=0
salcal2=(p_max - o_max)/o_max *100
'response.write o_max & "<br>"
'response.write p_max & "<br>"
'response.write salcal2
if salcal >=0 and salcal <=10 then
salary1="100"
elseif salcal >=11 and salcal <=20 then
salary1="80"
elseif salcal >=21 and salcal <= 30 then
salary1="60"
elseif salcalsalcal >=31 and salcal <= 40 then
salary1="20"
else salary1=30
end if
response.write salary1 & "<br>"
'response.end
tsalary=CDbl(salary)+CDbl(salary1)
'response.write salary& "<br>"
'response.write salary1& "<br>"
'response.write tsalary& "<br>"
tsalary=CDbl(tsalary)*15
response.write tsalary & "<br>"
'response.end
QUESTIONS=0
DO While not rt.EOF
o_questionid=p_questionid
if O_questionID = P_questionID then
questions=questions+2
else
questions =questions
end if
rt.movenext
loop
QUESTIONS=QUESTIONS*15
response.write questions & "<br>"
'response.end
lifestyle=0
if strclakes = 1 then
lifestyle=lifestyle+(strlakes*2.5)
end if
if strcdine = 2 then
lifestyle=lifestyle+(strdine*2.5)
end if
if strcart = 4 then
lifestyle=lifestyle+(strart*2.5)
end if
if strcairport = 8 then
lifestyle=lifestyle+(strairport*2.5)
end if
lifestyle=lifestyle*15
response.write lifestyle & "<br>"
'response.end
rating=cint(QUESTIONS)+cint(tsalary)+cint(qualifications)+cint(lifestyle)+cint(geography)
RESPONSE.WRITE RATING & "<br>"
txtsql ="INSERT INTO rating (opportunityid,physicianID,rating)values ('" & StropportunityID & "','" & strphysicianid &"', '" & rating & "')"
conn.Execute txtsql
'RESPONSE.End
'rt.Close(how to comment this out for the 2nd loop to work)
'Set rt= nothing
oRScp.movenext
loop
set oRScp = nothing
set conn = nothing