This topic is locked

What is wrong with this code?

8/28/2009 7:35:29 PM
ASPRunnerPro General questions
R
Rhoffman author

I have the below code in an AfterEdit event. All field and table names are correct. Query works in SQL Server, but not when I edit progress in the software.
if oldvalues("progress")<>values("progress") then

strSQLInsert=""

strSQLInsert= "update tbl_Migration set dtProgUpd=getdate() where mig_id=" & values("Mig_ID")

dbConnection.Execute strSQLInsert

End if
Any help is appreciated.

R
Rhoffman author 9/2/2009

I have done further research into this iss and have found that the issue is with this portion of the code:
if oldvalues("progress")<>values("progress") then
While I change the value of Progress, apparently ASP sees that they do not change. Either that or I am not using oldvalues and values correctly.
Any thought?????

C
clig 9/2/2009



I have done further research into this iss and have found that the issue is with this portion of the code:
if oldvalues("progress")<>values("progress") then
While I change the value of Progress, apparently ASP sees that they do not change. Either that or I am not using oldvalues and values correctly.
Any thought?????


Have you tried comparing values in BeforeEdit instead?
And I noticed Jane added: flush_output to another example in a post using values... not sure on this
http://www.asprunner.com/forums/index.php?/topic/12610-check-if-record-exists/pagehlvalues(fromsearch1
flush_output

if oldvalues("progress")<>values("progress") then

strSQLInsert=""

strSQLInsert= "update tbl_Migration set dtProgUpd=getdate() where mig_id=" & values("Mig_ID")

dbConnection.Execute strSQLInsert

End if

R
Rhoffman author 9/2/2009

Yes, I have tried adding it to the BeforeEdit section and the field is still NULL after changing the value of the progress field.

C
clig 9/3/2009



Yes, I have tried adding it to the BeforeEdit section and the field is still NULL after changing the value of the progress field.


you could do an edit onload:
strSQLExists = "SELECT TicketNo, SYSType, CustomerNo, ProjectNo, Customer, DateEntered, EnteredBy, NTSSSkillset, SIMSRegion, SIMSTicketNo, ITIL, Status, Priority, Description, SLADateTime, AssignedTo FROM NTSS_Tickets_Strip Where TicketNo = " & Request.QueryString("editid1")

set rsExists = CreateObject("ADODB.Recordset")

rsExists.Open strSQLExists, dbConnection

if not rsExists.eof then

Session("TicketNo") = rsExists("TicketNo")

Session("SYSType") = rsExists("SYSType")

Session("CustomerNumber") = rsExists("CustomerNo")

Session("CustomerNo") = rsExists("CustomerNo")

Session("ProjectNo") = rsExists("ProjectNo")

Session("Customer") = rsExists("Customer")

Session("DateEntered") = rsExists("DateEntered")

Session("EnteredBy") = rsExists("EnteredBy")

Session("NTSSSkillset") = rsExists("NTSSSkillset")

Session("SIMSRegion") = rsExists("SIMSRegion")

Session("SimsTicketNo") = rsExists("SIMSTicketNo")

Session("ITIL") = rsExists("ITIL")

Session("Status") = rsExists("Status")

Session("Priority") = rsExists("Priority")

Session("Description") = rsExists("Description")

Session("SLADateTime") = rsExists("SLADateTime")

Session("AssignedTo") = rsExists("AssignedTo")

Session("NTSSSkillset1") = rsExists("NTSSSkillset")

Session("NTSSTicketNo") = Request.QueryString("editid1")
else
end if

rsExists.Close : set rsExists = Nothing
then on afteredit
strSQLExists = "SELECT TicketNo, SYSType, CustomerNo, ProjectNo, Customer, DateEntered, EnteredBy, NTSSSkillset, SIMSRegion, SIMSTicketNo, ITIL, Status, Priority, Description, SLADateTime, AssignedTo FROM NTSS_Tickets_Strip Where TicketNo = " & Session("NTSSTicketNo")

set rsExists = CreateObject("ADODB.Recordset")

rsExists.Open strSQLExists, dbConnection

if not rsExists.eof then

Session("TicketNo") = rsExists("TicketNo")

Session("SYSType") = rsExists("SYSType")

Session("CustomerNumber") = rsExists("CustomerNo")

Session("CustomerNo") = rsExists("CustomerNo")

Session("ProjectNo") = rsExists("ProjectNo")

Session("Customer") = rsExists("Customer")

Session("DateEntered") = rsExists("DateEntered")

Session("EnteredBy") = rsExists("EnteredBy")

Session("NTSSSkillset") = rsExists("NTSSSkillset")

Session("SIMSRegion") = rsExists("SIMSRegion")

Session("SimsTicketNo") = rsExists("SIMSTicketNo")

Session("ITIL") = rsExists("ITIL")

Session("Status") = rsExists("Status")

Session("Priority") = rsExists("Priority")

Session("Description") = rsExists("Description")

Session("SLADateTime") = rsExists("SLADateTime")

Session("AssignedTo") = rsExists("AssignedTo")
else
end if

rsExists.Close : set rsExists = Nothing
' Check if Skillset changed

If Session("NTSSSkillset1") <> Session("NTSSSkillset") Then

  • a workaround but I don't see what's wrong with unless of course it's "values("blah")"...
  • or work with if oldvalues("progress") <> dict("progress") then
  • or work with if oldvalues("progress") <> GetRequestForm("progress") then
    example
    Sub AfterEdit(dict, oldvalues,keys,inline)

    If dict("Action_Item") = "Private" Then
    Else
    Dim dkeys

    message = ...

    sendmail email, subject, message
    End If

    End Sub