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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with update

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I am getting a timeout error on an update command for the database and have no clue why I am getting it. considering a page that has pretty much the same code works. Here is my code

dbrs3.open ("Select * From employeeinfo where loginID = '" & request.form("employee1") & "'"), dbconn, 2, 3


Dim vacation
Dim overtime
Dim personal
Dim medical
Dim volunteer
Dim extended
vacation = (request.form("vacation") - request.form("vacationtime"))
overtime = (request.form("over_time") * 0 + request.form("overtime"))
personal = (request.form("personal") - request.form("personaltime"))
volunteer = (request.form("volunteer") - request.form("volunteertime"))
medical = (request.form("medical") - request.form("medicalleave"))
if request.Form(&quot;medical&quot;) <= &quot;0&quot; Then
extended = (request.form(&quot;extended&quot;) - request.form(&quot;extendedtime&quot;))
end if

dbrs3.movefirst
do while NOT dbrs3.EOF
dbrs3(&quot;vacationtime&quot;)= vacation
dbrs3(&quot;overtime&quot;)= overtime
dbrs3(&quot;personalTime&quot;)= personal
dbrs3(&quot;volunteertime&quot;) = volunteer
dbrs3(&quot;medicalleave&quot;) = medical
if request.Form(&quot;medical&quot;) <= &quot;0&quot; Then
dbrs3(&quot;extendedtime&quot;) = extended
End if
dbrs3.update ' Error on this line.
dbrs3.movenext
loop
 
Try to use single UPDATE statement

UPDATE employeeinfo SET vacationtime = &quot; & vacation & &quot;, overtime = &quot; & overtime & &quot; ... etc ...
where loginID = '&quot; & request.form(&quot;employee1&quot;) & &quot;'&quot;),

 
I get a timeout error when I switch to this

dbrs3.open (&quot;UPDATE employeeinfo SET vacationtime = &quot; & vacation & &quot;, overtime = &quot; & overtime & &quot; where loginID = '&quot; & request.form(&quot;employee1&quot;) & &quot;'&quot;), dbconn, 2, 3
 
Don't open a recordset, try dbconn.execute(sql)

where sql = &quot;UPDATE...&quot;
 
the first thing that screams out at me is the dangerous way in which you construct your dynamic SQL statement. NEVER trust user data to be submitted in the format you expect.

dbrs3.open (&quot;Select * From employeeinfo where loginID = '&quot; & request.form(&quot;employee1&quot;) & &quot;'&quot;), dbconn, 2, 3

if someone were to submit a bogus form with &quot;employee1&quot; containing something like &quot;' DELETE FROM employeeinfo;&quot; then your code would construct a very bad SQL statement. ALWAYS validate user input, never trust that it has not been tampered with. at the very least, create a function to &quot;double-quote&quot; any user input...

Function makeSqlSafe(strInput)
makeSqlSafe = Replace(strInput,&quot;'&quot;,&quot;''&quot;)
End Function

then use makeSqlSafe(Request.Form(&quot;employee1&quot;)) and you are minimally covered.

good luck!
 
I still get a timeout when I use this

dbconn.execute(&quot;UPDATE employeeinfo SET vacationtime = &quot; & vacation & &quot;, overtime = &quot; & overtime & &quot; where loginID = '&quot; & request.form(&quot;employee1&quot;) & &quot;'&quot;)
dbrs3(&quot;vacationtime&quot;)= vacation
 
Try to execute the SQL statement directly against the database (not in the ASP) with the same data and see if you get any errors on the statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top