Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i calculate values retieved from a database

Status
Not open for further replies.

chryso

Programmer
Apr 25, 2001
2
GB
Desperate Help Needed!!!!!!!!!!!
I have retrieved stored values from the database, but how can i
convert them to be used for a calculation and how can i apply
the select statement to get the correct BasicPay calculation.....

Please help....Desperately...Chryso....Thanxs

<%
Dim BasicPay, Payfreq, PayRate, StdHours
Dim objRS ' recordset object
Set objRS = Server.CreateObject (&quot;ADODB.Recordset&quot;) ' create recordset object
objRS.Open &quot;Personal&quot;, objConn, _
adOpenForwardOnly, adLockReadOnly, adCmdTable ' now open it


Response.Write &quot; You are paid &quot; & objRS.Fields(&quot;Payfreq&quot;) & &quot;,<BR> &quot;
Response.Write &quot;Your rate of pay is £&quot; & objRS.Fields(&quot;PayRate&quot;) & &quot; per hour &quot; & &quot;, <BR>&quot;
Response.Write &quot;You have worked &quot; & objRS.Fields(&quot;stdHours&quot;) & &quot; hours &quot; & objRS.Fields(&quot;Payfreq&quot;) & &quot;, <BR>&quot;
objRS.Close ' now close it
Set objRS = Nothing ' ...and clean up

%>

<% Select case Payfreq
case &quot;Weekly&quot;
BasicPay = Payrate * StdHours
case &quot;Monthly&quot;
BasicPay = (PayRate * StdHours)*4
End Select %>
 
Use the Cint() and/or CDbl() functions.

br
Gerard
(-:

Better a known bug then a new release.
 
You need to assign the rs values to your variables:

Code:
Dim BasicPay, Payfreq, PayRate, StdHours
Dim objRS              ' recordset object
Set objRS = Server.CreateObject (&quot;ADODB.Recordset&quot;)    ' create recordset object
objRS.Open &quot;Personal&quot;, objConn, _
             adOpenForwardOnly, adLockReadOnly, adCmdTable           ' now open it

Payfreq = objRS.Fields.item(&quot;Payfreq&quot;).value
PayRate = objRS.Fields.item(&quot;PayRate&quot;).value
StdHours = objRS.Fields.item(&quot;StdHours&quot;).value

Response.Write &quot; You are paid &quot; & PayFreq & &quot;,<BR> &quot;
Response.Write &quot;Your rate of pay is £&quot; & PayRate & &quot; per hour &quot; & &quot;, <BR>&quot;
Response.Write &quot;You have worked &quot; & StdHours & &quot; hours &quot; & Payfreq & &quot;, <BR>&quot;
objRS.Close                    ' now close it
Set objRS = Nothing            ' ...and clean up
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top