0

I am returning a value from my database. The data type is a string. I checked with TypeName. However, my if condition never works despite it printing the value I am checking for. Any ideas?

while NOT prs.EOF

    RecordStatus = prs("status")


    If (RecordStatus = "S") Then
        response.write("Scheduled!<br>")
        prs.MoveNext
    Else
        response.write(RecordStatus & "<BR>")
        prs.MoveNext
   End If

Wend
prs.Close
4

2 回答 2

2

此外,请考虑将 MoveNext 放在最后一行。

while NOT prs.EOF

    RecordStatus = prs("status")    

    If (Trim(RecordStatus) = "S") Then
        response.write("Scheduled!<br>")
    Else
        response.write(RecordStatus & "<BR>")
    End If

    prs.MoveNext    
Wend
prs.Close
于 2013-02-06T21:17:56.600 回答
0

Same result, half the code:

do while NOT prs.EOF
    RecordStatus = ucase(trim(prs("status")))
    If RecordStatus = "S" Then response.write "Scheduled!<br>" Else response.write RecordStatus & "<br>"
    prs.MoveNext
loop
prs.close

You could also do this logic check with a case statement inside the SQL query itself:

select case lower(status) when 's' then 'Scheduled!' else status end as sresult from <yourdatabase>

Then use the code:

do while NOT prs.EOF
    sresult = prs("sresult") & "<br>"
    response.write sresult
    prs.MoveNext
loop
prs.close

Hope it help :)

于 2013-02-08T04:55:19.940 回答