ASP Error ’80020009′

Again today, I came across an error caused by an invalid date value. The error reported was:

  1. error '80020009'
  2. Exception occurred.
  3. /somefile.asp, line <number>

Went and googled again, this time it appeared as though the error was commonly caused by over-stepping the bounds of the resultset. For instance, pulling back 10 records by trying to read the 11th which doesn’t exist. Well that wasn’t the case for mine (once again), it was an invalid date format.

All I was doing, was displaying the date value. I wasn’t using it to do any calculations in either ASP or through SQL, so even it if was invalid, you would assume it would just ‘display it’ and be done with it.

For whatever reason, just trying to display a date of format ’0000-01-04′ caused it to fall over. The solution of course, just correct the date value. Once again, lack of client and server side checking of user input bites you in the arse.

Related posts:

  1. More ASP Error ’80020009′
  2. ASP Error ’0×80004005′
  3. ASP Error ‘ASP 0104: 80004005′
  4. ORA-06502: PL/SQL: numeric or value error
  5. ASP Error ’800a000d’

About Al

My name is Alistair Lattimore, I'm in my very early 30's and live on the sunny Gold Coast in Australia. I married my high school sweet heart & we've been together for longer than I can remember. Claire and I started our family in September 2008 when Hugo was born and added a gorgeous little girl named Evie in May 2010. You can find me online in the typical hangouts, Google, Twitter & facebook. .
This entry was posted in Database, Programming. Bookmark the permalink.

11 Responses to ASP Error ’80020009′

  1. menka says:

    why does occure this problem?

  2. Al says:

    To be brutally honest menka, I don’t know. I’ve mentioned before that the error reporting from ASP, has a lot to be desired. They use the same error code for many many different errors; when in fact the errors (after my investigations at least), seem wildly different.

    You need to whittle down the error, narrowing the possibilities each time.

    What are you doing when you get the error? Are you using a database for instance, is the error happening when accessing a resultset from a query, is it something else?

    You would need to give me some insight for me to be able to help you at all.

  3. sreekumar says:

    i got the same error but its due to the null value in the parameter

  4. FRiTZ says:

    Thanks,
    Although my problem wasn’t an invalid date value, your explaination helped. My problem was actually caused by over-stepping the bounds of the resultset. I just hadn’t thought of that.

  5. prabhu says:

    when i m trying to retrive more records from oracle database using asp page its showing exception error

  6. Al says:

    There is no reason for ASP to generate that error, simply because you’ve selected more than one record. It is more likely that you’re accessing the records incorrectly. A simple method to make sure you don’t ever overstep the resultset is:

    1. Dim cn, sSQL, oRS
    2. Set cn = Server.CreateObject("ADODB.Connection")
    3. cn.Open sDSN
    4. sSQL = "SELECT field FROM table_name WHERE something = 1"
    5. Set oRS = cn.execute(sSQL)
    6. If Not oRS.EOF Then
    7. While Not oRS.EOF
    8. Response.Write "field=" & oRS("field")
    9. oRS.MoveNext
    10. WEnd
    11. oRS.Close
    12. End If
    13. cn.Close
    14. Set oRS = Nothing
    15. Set cn = Nothing

    Using the above method, you’ll never overstep the resultset. The reason this won’t happen is the Not oRS.EOF condition. So you will only ever go into the While loop if the current read position in the recordset isn’t the last record in the set.

  7. Chris says:

    Just googled upon this as I was getting the same error. However, I have a slightly different scenario. Essentially I load data into a Dictionary object to be displayed further along in the processing, like so:


    oDict.Add key, rs.Fields( fieldname )

    Set rs = Nothing

    Response.Write oDict( key ) ‘ Error occurs here

    The problem is I have blindly assumed that the VALUE of rs.Fields( fieldname ) will be added to the dictionary, when in fact a REFERENCE to the Field object is being added, which of course went out of scope the moment I set the parent ResultSet to Nothing.

  8. Al says:

    Chris,

    As with every language, you will nearly always have scoping problems at some point. The trick is knowing how your particular language scopes variables. I thought VBScript passed/assigned using a ByVal method instead of ByRef by default, I’ll have to look into that jus to clarify for myself.

    Al.

  9. Dennis says:

    I am having a similar problem and getting the error as follows:

    50 FAQs This shows that faqnum.Count is returning the correct value
    error ’80020009′ Trying to read faqnum.Item(faq) where faq = 1
    /spfaq.asp, line 87
    The dictionary object in loaded from a database using Set rsFAQs = Server… and I have left rsFAQs open afterwards.
    Any help is gratefully received.

  10. Raphael says:

    I recently had the same problem using the Dictionary object.

    You can fix this error by casting your key into String. Don’t know why, but it will fix the problem on Error ’80020009′.

    Fix this by putting (example) :
    Response.Write oDict(CStr(key))

  11. Brandon says:

    Is there any reason you can think of that the error would ONLY occur in IE6? Firefox, Safari, Mac, PC doesn’t seem to matter… but IE6 shows that error.

    I’m completely stumped. Server-side errors shouldn’t matter what browser the user has.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>