NOPOPNOSTYLE
IS-IT--Management
Hi there
I've written some code to check a variable against a scale thats held in a table and pulled back in a recordset, the idea is to loop through the table and exit for when the condition is true, however the code only works when the variables value is lower than the min of the first row of the scale table. I've put the code below, any help would be appreciated.
Lord Exell
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<%
VAR_NAME=Request.querystring("ID")
Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = "file name=" & Server.MapPath(".") & "\database\udl_managers.udl"
objComm.CommandType = &H0001
'This is Recordset for the Scale
objComm.CommandText = "SELECT * FROM RP_1_MAN_DISC_SCALE"
set RS_SCALE = objComm.Execute
'This is Recordset to determine number of rows in the Scale Currently 5 Rows
objComm.CommandText = "SELECT Count(MAN_DISC_SCALE.ID) AS CountOfID FROM MAN_DISC_SCALE"
set RS_COUNTER = objComm.Execute
'This is Recordset for the Managers Score, currently=2
objComm.CommandText = "SELECT * FROM RP_2_MAN_DISC_AWARD Where PAYROLL_NUM=7728"
set RS_SCORE = objComm.Execute
'assign the Managers Score from RS_SCORE as a variable as there is only 1 row selected from RS_SCORE
VAR_ONE=Cint(RS_SCORE("RP_2_MAN_DIS_AWARD"))'value here is 2
'assign the number from RS_COUNTER as a variable as there is only 1 row selected from RS_COUNTER
VAR_TWO=Cint(RS_COUNTER("CountOfID"))'value here is 5
For I = 1 To VAR_TWO 'VAR_TWO is equal to 5
If VAR_SCORE < RS_SCALE("ZFROM") Then 'values for ZFROM are Row1=1 etc till Row5=5
'If I replace VAR_SCORE in the above line with 0 the code works a number above 0 does not.
VAR_RES=RS_SCALE("PTS") 'values for PTS are double row 2 ie Row1=2 pts till Row5=10 pts
Exit For
End IF
Next
%>
<body>
<%
Response.Write(VAR_RES)
'VAR_RES value should be 4 but the code does not seem to be looping correctly
%>
<%'Response.Write(VAR_ONE)%><br>
<%'Response.Write(VAR_TWO)%><br>
</body>
</html>
<%
Set RS_SCALE = Nothing
Set RS_SCORE = Nothing
Set RS_COUNTER = Nothing
Set objComm = Nothing
%>
I've written some code to check a variable against a scale thats held in a table and pulled back in a recordset, the idea is to loop through the table and exit for when the condition is true, however the code only works when the variables value is lower than the min of the first row of the scale table. I've put the code below, any help would be appreciated.
Lord Exell
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<%
VAR_NAME=Request.querystring("ID")
Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = "file name=" & Server.MapPath(".") & "\database\udl_managers.udl"
objComm.CommandType = &H0001
'This is Recordset for the Scale
objComm.CommandText = "SELECT * FROM RP_1_MAN_DISC_SCALE"
set RS_SCALE = objComm.Execute
'This is Recordset to determine number of rows in the Scale Currently 5 Rows
objComm.CommandText = "SELECT Count(MAN_DISC_SCALE.ID) AS CountOfID FROM MAN_DISC_SCALE"
set RS_COUNTER = objComm.Execute
'This is Recordset for the Managers Score, currently=2
objComm.CommandText = "SELECT * FROM RP_2_MAN_DISC_AWARD Where PAYROLL_NUM=7728"
set RS_SCORE = objComm.Execute
'assign the Managers Score from RS_SCORE as a variable as there is only 1 row selected from RS_SCORE
VAR_ONE=Cint(RS_SCORE("RP_2_MAN_DIS_AWARD"))'value here is 2
'assign the number from RS_COUNTER as a variable as there is only 1 row selected from RS_COUNTER
VAR_TWO=Cint(RS_COUNTER("CountOfID"))'value here is 5
For I = 1 To VAR_TWO 'VAR_TWO is equal to 5
If VAR_SCORE < RS_SCALE("ZFROM") Then 'values for ZFROM are Row1=1 etc till Row5=5
'If I replace VAR_SCORE in the above line with 0 the code works a number above 0 does not.
VAR_RES=RS_SCALE("PTS") 'values for PTS are double row 2 ie Row1=2 pts till Row5=10 pts
Exit For
End IF
Next
%>
<body>
<%
Response.Write(VAR_RES)
'VAR_RES value should be 4 but the code does not seem to be looping correctly
%>
<%'Response.Write(VAR_ONE)%><br>
<%'Response.Write(VAR_TWO)%><br>
</body>
</html>
<%
Set RS_SCALE = Nothing
Set RS_SCORE = Nothing
Set RS_COUNTER = Nothing
Set objComm = Nothing
%>