Request object error 'ASP 0105 : 80004005' ( Index out of range )

Discussion in 'ASP General' started by Andy, Feb 6, 2004.

  1. Andy

    Andy Guest

    hI,
    wOULD PLEASE HELP ME. I AM GETTIGN THE REQUEST OBJECT ERROS ASP 0105:
    80004005 INDEX OUT OF RANGE ERROR. HERE IS THE SNIPPET OF CODE THAT I
    AM USING. WHAT IS WRONG HERE? YOU CAN SEE WHAT I AM TRYING TO DO ADN
    ERROR ON THIS LINK: http://www.walani.com/ProjectFiles/01_main.asp.

    PLEASE HELP

    <%
    Dim iQuestions 'Holds the question
    Dim nScore ' Holds the number of answer

    'Set nScore to highest possible score
    nScore = 3

    iQuestions = 1
    While Not objRS.EOF

    '==================THIS IS WHERE THE ERROR IS
    If Request.Form(objRS("QID")) = objRS("QCorrectAnswer") Then
    bRightWrong = 1
    Else
    bRightWrong = 0
    '~~~~~Set minus by number For how much Is counted off For Each
    question~~~~~~
    nScore = nScore - 1

    End If
    '~~~~Save the answers and grade to each question~~~~~~
    strSQL = "INSERT INTO tblStudentTests
    (STUserID,STQID,STAnswer,STRightWrong) VALUES ('" &
    Request.Cookies("LoginData")("Login") & "@" &
    Request.Cookies("LoginData")("Pass") & "', " & objRS("QID") & ",'" &
    Request.Form(objRS("QID")) & "','" & bRightWrong & "')"
    objConn.Execute(strSQL)

    '~~~~~Show Question with Student answer and Grade~~~~~~
    Response.Write(iQuestions & ". " & objRS("QQuestion") & ":<BR>")
    Response.Write("Your Answer: " & Request.Form(objRS("QID")) & "<BR>")
    Response.Write("<B>" & bRightWrong & "</B><BR><BR>")
    objRS.MoveNext
    iQuestions = iQuestions + 1
    wend
    %>


    ANDY
     
    Andy, Feb 6, 2004
    #1
    1. Advertising

  2. Andy

    Bob Barrows Guest

    When I saw the all-caps, I almost deleted the message without reading it.
    Please do not shout in the future. It makes your message hard to read. See
    below for my response:

    Andy wrote:

    > While Not objRS.EOF
    >
    > '==================THIS IS WHERE THE ERROR IS


    To be able to help you, we need to know what is contained in objRS("QID")
    and the names and values of your form variables in Request. So do this:

    Response.Write "QID contains :" & objRS("QID") & "<BR>"
    Response.Write "The Form collection contains:<BR>"
    for each key in Request.Form
    Response.Write key & ": " & Request.Form(key) & "<BR"
    next
    response.end

    If running this fails to show you what's wrong, post the results back here
    so we can look at it.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Feb 6, 2004
    #2
    1. Advertising

  3. Andy

    Andy K Guest

    Re: Request object error 'ASP 0105 : 80004005' ( Index out of range)

    Thanks bob. I have done what you suggested and here are the results from
    your suggested code

    QID contains :1
    The Form collection contains:
    1: Junkyard Wars<BR2: In my car<BR31: programming Language<BR

    It looks like in the collection it is reading the second line before the
    first one. I have checked in my database and th tables are linked
    accordingly. One table has a list of questions with the correct answer.
    Another table has a list of possible answers and i have linked this
    using the question ID
    Thanks once again.
    What is wrong?

    Bob Barrows wrote:
    > When I saw the all-caps, I almost deleted the message without reading it.
    > Please do not shout in the future. It makes your message hard to read. See
    > below for my response:
    >
    > Andy wrote:
    >
    >
    >>While Not objRS.EOF
    >>
    >>'==================THIS IS WHERE THE ERROR IS

    >
    >
    > To be able to help you, we need to know what is contained in objRS("QID")
    > and the names and values of your form variables in Request. So do this:
    >
    > Response.Write "QID contains :" & objRS("QID") & "<BR>"
    > Response.Write "The Form collection contains:<BR>"
    > for each key in Request.Form
    > Response.Write key & ": " & Request.Form(key) & "<BR"
    > next
    > response.end
    >
    > If running this fails to show you what's wrong, post the results back here
    > so we can look at it.
    >
    > Bob Barrows
     
    Andy K, Feb 6, 2004
    #3
  4. Andy

    Andy K Guest

    Re: Request object error 'ASP 0105 : 80004005' ( Index out of range)

    Thanks Bob here are the results of what you suggested. It seems to work
    as it picks up the correct object
    QID contains :2
    The Form collection contains:
    1: Active Server Pages
    2: In my car
    31: Don’t know

    So what can be wrong then?
    Thanks in advance for your help.

    Andy


    Bob Barrows wrote:

    > When I saw the all-caps, I almost deleted the message without reading it.
    > Please do not shout in the future. It makes your message hard to read. See
    > below for my response:
    >
    > Andy wrote:
    >
    >
    >>While Not objRS.EOF
    >>
    >>'==================THIS IS WHERE THE ERROR IS

    >
    >
    > To be able to help you, we need to know what is contained in objRS("QID")
    > and the names and values of your form variables in Request. So do this:
    >
    > Response.Write "QID contains :" & objRS("QID") & "<BR>"
    > Response.Write "The Form collection contains:<BR>"
    > for each key in Request.Form
    > Response.Write key & ": " & Request.Form(key) & "<BR"
    > next
    > response.end
    >
    > If running this fails to show you what's wrong, post the results back here
    > so we can look at it.
    >
    > Bob Barrows
     
    Andy K, Feb 6, 2004
    #4
  5. Andy

    Bob Barrows Guest

    Andy K wrote:
    > Thanks Bob here are the results of what you suggested. It seems to
    > work
    > as it picks up the correct object
    > QID contains :2
    > The Form collection contains:
    > 1: Active Server Pages
    > 2: In my car
    > 31: Don’t know
    >
    > So what can be wrong then?
    > Thanks in advance for your help.
    >
    > Andy
    >
    >
    > Bob Barrows wrote:
    >
    >> When I saw the all-caps, I almost deleted the message without
    >> reading it. Please do not shout in the future. It makes your message
    >> hard to read. See below for my response:
    >>
    >> Andy wrote:
    >>
    >>
    >>> While Not objRS.EOF
    >>>
    >>> '==================THIS IS WHERE THE ERROR IS

    >>
    >>
    >> To be able to help you, we need to know what is contained in
    >> objRS("QID") and the names and values of your form variables in
    >> Request. So do this:
    >>
    >> Response.Write "QID contains :" & objRS("QID") & "<BR>"
    >> Response.Write "The Form collection contains:<BR>"
    >> for each key in Request.Form
    >> Response.Write key & ": " & Request.Form(key) & "<BR"
    >> next
    >> response.end
    >>
    >> If running this fails to show you what's wrong, post the results
    >> back here so we can look at it.
    >>
    >> Bob Barrows


    I suspect that in this line:

    If Request.Form(objRS("QID")) = objRS("QCorrectAnswer") Then

    the content of objRS("QID") is being interpreted as a number (why are you
    using numbers for your form field names?) instead of a string, so instead of
    looking for a form variable named "31", it's looking for the 31st item in
    the form variables collection, which just isn't there.

    As an initial try at working around this, you might try this:

    If Request.Form(CStr(objRS("QID"))) = objRS("QCorrectAnswer") Then

    If that does not work, then I suggest adding an alpha character to your form
    field names, so that instead of being named 1,2,31, they are named f1, f2.
    f31. This will allow you to do this:

    If Request.Form("f" & objRS("QID")) = objRS("QCorrectAnswer") Then


    HTH,
    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Feb 6, 2004
    #5
  6. Andy

    Andy K Guest

    Re: Request object error 'ASP 0105 : 80004005' ( Index out of range)

    Bob,
    I triedn converting the whole thing to a string as you suggested adn
    that doesn't work as well.
    Infact in my form name field is the same as the QID, which is an
    AutoNumber in the access database. This is how I have assigned it.
    Response.Write("<INPUT TYPE='radio' NAME='" & objRS("QID") & " VALUE='"
    & objRS2("AAnswer") & "'>" & objRS2("AAnswer") & "<BR>")

    This is on a different form.

    Any Ideas, Thanks Bob

    Bob Barrows wrote:

    > Andy K wrote:
    >
    >>Thanks Bob here are the results of what you suggested. It seems to
    >>work
    >>as it picks up the correct object
    >>QID contains :2
    >>The Form collection contains:
    >>1: Active Server Pages
    >>2: In my car
    >>31: Don’t know
    >>
    >>So what can be wrong then?
    >>Thanks in advance for your help.
    >>
    >>Andy
    >>
    >>
    >>Bob Barrows wrote:
    >>
    >>
    >>>When I saw the all-caps, I almost deleted the message without
    >>>reading it. Please do not shout in the future. It makes your message
    >>>hard to read. See below for my response:
    >>>
    >>>Andy wrote:
    >>>
    >>>
    >>>
    >>>>While Not objRS.EOF
    >>>>
    >>>>'==================THIS IS WHERE THE ERROR IS
    >>>
    >>>
    >>>To be able to help you, we need to know what is contained in
    >>>objRS("QID") and the names and values of your form variables in
    >>>Request. So do this:
    >>>
    >>>Response.Write "QID contains :" & objRS("QID") & "<BR>"
    >>>Response.Write "The Form collection contains:<BR>"
    >>>for each key in Request.Form
    >>> Response.Write key & ": " & Request.Form(key) & "<BR"
    >>>next
    >>>response.end
    >>>
    >>>If running this fails to show you what's wrong, post the results
    >>>back here so we can look at it.
    >>>
    >>>Bob Barrows

    >
    >
    > I suspect that in this line:
    >
    > If Request.Form(objRS("QID")) = objRS("QCorrectAnswer") Then
    >
    > the content of objRS("QID") is being interpreted as a number (why are you
    > using numbers for your form field names?) instead of a string, so instead of
    > looking for a form variable named "31", it's looking for the 31st item in
    > the form variables collection, which just isn't there.
    >
    > As an initial try at working around this, you might try this:
    >
    > If Request.Form(CStr(objRS("QID"))) = objRS("QCorrectAnswer") Then
    >
    > If that does not work, then I suggest adding an alpha character to yourform
    > field names, so that instead of being named 1,2,31, they are named f1, f2.
    > f31. This will allow you to do this:
    >
    > If Request.Form("f" & objRS("QID")) = objRS("QCorrectAnswer") Then
    >
    >
    > HTH,
    > Bob Barrows
     
    Andy K, Feb 9, 2004
    #6
  7. Andy

    Andy K Guest

    Re: Request object error 'ASP 0105 : 80004005' ( Index out of range)

    Thanks Bob,
    It worked as you suggested. I had to conver everythign to string.

    great, many thanks

    Andy K wrote:

    > Bob,
    > I triedn converting the whole thing to a string as you suggested adn
    > that doesn't work as well.
    > Infact in my form name field is the same as the QID, which is an
    > AutoNumber in the access database. This is how I have assigned it.
    > Response.Write("<INPUT TYPE='radio' NAME='" & objRS("QID") & " VALUE='"
    > & objRS2("AAnswer") & "'>" & objRS2("AAnswer") & "<BR>")
    >
    > This is on a different form.
    >
    > Any Ideas, Thanks Bob
    >
    > Bob Barrows wrote:
    >
    >> Andy K wrote:
    >>
    >>> Thanks Bob here are the results of what you suggested. It seems to
    >>> work
    >>> as it picks up the correct object
    >>> QID contains :2
    >>> The Form collection contains:
    >>> 1: Active Server Pages
    >>> 2: In my car
    >>> 31: Don’t know
    >>>
    >>> So what can be wrong then?
    >>> Thanks in advance for your help.
    >>>
    >>> Andy
    >>>
    >>>
    >>> Bob Barrows wrote:
    >>>
    >>>
    >>>> When I saw the all-caps, I almost deleted the message without
    >>>> reading it. Please do not shout in the future. It makes your message
    >>>> hard to read. See below for my response:
    >>>>
    >>>> Andy wrote:
    >>>>
    >>>>
    >>>>
    >>>>> While Not objRS.EOF
    >>>>>
    >>>>> '==================THIS IS WHERE THE ERROR IS
    >>>>
    >>>>
    >>>>
    >>>> To be able to help you, we need to know what is contained in
    >>>> objRS("QID") and the names and values of your form variables in
    >>>> Request. So do this:
    >>>>
    >>>> Response.Write "QID contains :" & objRS("QID") & "<BR>"
    >>>> Response.Write "The Form collection contains:<BR>"
    >>>> for each key in Request.Form
    >>>> Response.Write key & ": " & Request.Form(key) & "<BR"
    >>>> next
    >>>> response.end
    >>>>
    >>>> If running this fails to show you what's wrong, post the results
    >>>> back here so we can look at it.
    >>>>
    >>>> Bob Barrows

    >>
    >>
    >>
    >> I suspect that in this line:
    >>
    >> If Request.Form(objRS("QID")) = objRS("QCorrectAnswer") Then
    >>
    >> the content of objRS("QID") is being interpreted as a number (why are you
    >> using numbers for your form field names?) instead of a string, so
    >> instead of
    >> looking for a form variable named "31", it's looking for the 31st itemin
    >> the form variables collection, which just isn't there.
    >>
    >> As an initial try at working around this, you might try this:
    >>
    >> If Request.Form(CStr(objRS("QID"))) = objRS("QCorrectAnswer") Then
    >>
    >> If that does not work, then I suggest adding an alpha character to
    >> your form
    >> field names, so that instead of being named 1,2,31, they are named f1,
    >> f2.
    >> f31. This will allow you to do this:
    >>
    >> If Request.Form("f" & objRS("QID")) = objRS("QCorrectAnswer") Then
    >>
    >>
    >> HTH,
    >> Bob Barrows

    >
    >
     
    Andy K, Feb 9, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UnVkeQ==?=

    Index was out of range ERROR <NEWBIE ERROR>

    =?Utf-8?B?UnVkeQ==?=, Jul 6, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    517
    =?Utf-8?B?UnVkeQ==?=
    Jul 6, 2005
  2. John Beschler
    Replies:
    1
    Views:
    218
    Philip Mattson
    Jul 30, 2003
  3. Charles Vaz

    ASP 0105 (0X80004005)

    Charles Vaz, Oct 9, 2003, in forum: ASP General
    Replies:
    3
    Views:
    152
    Bob Barrows
    Oct 10, 2003
  4. F. Nolet
    Replies:
    2
    Views:
    482
  5. Replies:
    4
    Views:
    490
    Bob Barrows [MVP]
    Jan 29, 2007
Loading...

Share This Page