Microsoft VBScript runtime error '800a01a8'  - Object required

Posted on 2006-05-30
Last Modified: 2008-01-09

I have a puzzling question.  i got the error Microsoft VBScript runtime error '800a01a8'  - Object required on  page 2 but when I click back to the Page1 and then click Submit again, the page works!  

what I'm trying to say is that it doesn't work the first time but is able to update on the second try (after I click the back Button  and then the Submit buttonin IE).    

This is the code on Page 2.

<!--#include file="../Connections/OnlineRegistration.asp" -->
<%  Dim con, sql_update
sql_update = "Update Pendaftaran Set Nama = '"& Session("NamaValue") &"', NIP = '"& Session("NIPValue") &"' Where PendaftaranID = " & Session("PendaftaranID") & " "
        Set con = Server.CreateObject("ADODB.Connection")
                  con.Open MM_OnlineRegistration_STRING                      --> Error line
        con.Execute sql_update  
        Set con = nothing
        Response.Redirect ("DaftarPerserta.asp?KursusID=" & Session ("KursusID"))

I'm sure it works cos it's able to update on the second try (but not the 1st time)
Question by:limhodav
    LVL 7

    Accepted Solution


    Can you response.Write the value of the MM_OnlineRegistration_STRING before the open so you can see if it is the same?
    Also, put an Option Explicit into the page at the top as this forces the runtime to do a few extra checks (But makes the code run slightly aster)


    Author Comment

    Have done so. It's exactly the same as the rest of the pages.  

    The funny thing is that it works first time when I run it under localhost.  But after uploading to actual site, it can only run on the second try.  This is perplexing.  

    Author Comment

    I've added Option Explicit and miraculously it worked .... don't understand why but happy as long as it works
    LVL 7

    Expert Comment

    Basically, when you use option explicit, the system scans the ASP for variables and objects used for and attempts to match them with Dim statements. Once it comes across one it creates an object store for it before executing the code.

    Under certain versions of the script engine, dynamically created objects didn't get properly initialised when they got thier Set statement until the page was cached in the ASP memory block. So on occasion you got that error. I learnt this from Microsoft on a specialist IIS course about 6 years ago where we tested different methods of coding in ASP... Had a great example of a piece of bad db access looping thru 100 records that through the cache engine ran about 20% faster than the proper way of doing it due to the way ASP cached stuff. Once it got to 120 records the thing reversed in performance...

    Author Comment

    Thanks a lot for enlightening me.  

    I'm actually only a part time programmer who self-taught ASP on his own through the internet.

    Perhaps, the first time when it didn't worked is due to the fact that the object has not been cached yet. After that, it can work on the 2nd time.  

    Thanks once again.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now