Classic ASP error "80020009" An exception has occurred

On line 5 of the code on the site I'm fixing, I'm getting an exception error from classic ASP. Line ** below is line 5. It looks like this feature is used on other pages on the site, although I don't quite understand why. I tried to just delete the code, but since it was using other places this should be important, so maybe I shouldn't try to delete it.

Private Function AE(myString)
**If myString <> "" then** 
AE = Replace(myString,"`","'")
End If
End Function

      

Here's a usage example AE

:response.write AE(rs("ArticleTitle"))

Thanks in advance for any help you can give me!

+3


source to share


4 answers


This probably means that the field in the database is Null. You can add this line before the problematic line:

If isNull( myString ) Then Exit Function

      



In case that doesn't work, you can also try changing the problematic line like this:

If "" & myString <> "" Then

      

+7


source


This error also occurs if you are trying to access a record in a recordset that has no records (i.e. if you forgot to check eof before accessing fields).



0


source


check before replacing if it does in line by

if instr(mystring, "`") then
'your code
else
'your code
end if

      

0


source


Use an ASCII character code instead of a separate quote:

AE = Replace(myString,"`",chr(39))

      

-2


source







All Articles