Need Help. - Can't find my error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gaby

    Need Help. - Can't find my error

    Hi guys,
    I have this ASP code that is a little long to post so but you can
    download it off of


    I cant find out what my error is. I know it is not in my Access
    because I have tested my query and it works fine. but whenever i try
    to submit from the page the imformation doesnt go thorugh. on a side
    note, if i hit refresh it tells me it cannot refresh without sending
    the information. i dont know if this would help any. please help me
    if you guys can. i need this for a very important research project at
    my university.

    Thanks again,
    Gabriel

  • Bob Barrows [MVP]

    #2
    Re: Need Help. - Can't find my error

    Gaby wrote:
    Hi guys,
    I have this ASP code that is a little long to post so but you can
    download it off of

    >
    I cant find out what my error is. I know it is not in my Access
    because I have tested my query and it works fine. but whenever i try
    to submit from the page the imformation doesnt go thorugh. on a side
    note, if i hit refresh it tells me it cannot refresh without sending
    the information. i dont know if this would help any. please help me
    if you guys can. i need this for a very important research project at
    my university.
    >
    You would be better off creating a small repro page that we can run
    ourselves. Strip out everything that is not related to the symptom you are
    experiencing and post it here. Provide details abot the database tables and
    queries.
    --
    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"


    Comment

    • Gaby

      #3
      Re: Need Help. - Can't find my error

      Heres the simplified version of the code. I will only include the code
      showing five questions, when the real one has over 120.....


      --

      <HTML>
      <HEAD>
      <TITLE>Survey : Traits and IT </TITLE>
      <Style type="text/css"body { Color: black; background: 99CCFF; }
      body { margin-left: 5%; margin-right: 5% }
      h1 { margin-left: -8%; }
      h2, h3, h4, h5 { margin-left: -4% }
      h2 { margin-top: 8em; margin-bottom: 3em; }
      p { text-indent: 2em; margin-top: 0; margin-bottom: 0; }
      body { font-family: Arial, sans-serif; }
      h1, h2 { font-family: Arial, Verdana, sans-serif; }
      div.box { border: solid; border-width: thin; width: 100% }
      div.color { background: rgb (204, 204, 255); padding: 0.5em; border:
      none ; }
      </Style>
      </HEAD>
      <BODY>
      <FORM name="frmtrial_ IPC" method="post" action="FormRes ponse.asp">
      <P>The following is the draft for a survey page.</P>
      <br>
      <Select name="Instructo r">
      <option value="" selected>Select Instructor</option>
      <option value="Ammons">
      Ammons</option>
      <option value="Norton">
      Norton</option>
      <option value="OTHER">
      Other</option>
      </Select>
      &nbsp; &nbsp;
      <Select name="Semester" >
      <option value="" selected>Select Semester</option>
      <option value="Spring20 06">
      Spring , 2006
      </option>
      <option value="SummerI2 006">
      Summer I , 2006</option>
      <option value="SummerII 2006">
      Summer II , 2006</option>
      <option value="Fall2006 ">
      Fall , 2006</option>
      </Select>
      Class Roster #: <input type="text" size="12" maxlength="6"
      name="roster" id="roster">
      <br>
      <Select name="Gender">
      <option value="" selected>Select Gender</option>
      <option value="Male"Mal e</option>
      <option value="Female"F emale</option>

      </Select>
      <input type="text" name="text1" id="text1">
      <br>
      <br>
      <input type="password" size="10" maxlength="15" name="password"
      value="MyPasswo rd" id="password">
      <HR>
      <BR>
      <BR>
      <I><B>Instructi ons:</I></BCheck (click) the box of each of the
      following
      words or phrases that would usually describe you. If you
      unintentionally or
      mistakenly a check a box, you may click it to uncheck.
      <BR>
      <BR>
      01. <input type="checkbox" id="1_AbleToGiv eOrders"
      name="1_AbleToG iveOrders" value="1">
      <label for="AbleToGive Orders">Able to give orders</label>
      <BR>
      02. <input type="checkbox" id="2_Appreciat ive" name="2_Appreci ative"
      value="1">
      <label for="Appreciati ve">Appreciativ e</label>
      <BR>
      03. <input type="checkbox" id="3_Apologeti c" name="3_Apologe tic"
      value="1">
      <label for="Apologetic ">Apologeti c</label>
      <BR>
      04. <input type="checkbox" id="4_AbleToTak eCareOfSelf"
      name="4_AbleToT akeCareOfSelf" value="1">
      <label for="AbleToTake CareOfSelf">Abl e to take care of self</label>
      <BR>
      <BR>
      05. <input type="checkbox" id="5_AcceptsAd viceReadily"
      Name="5_Accepts AdviceReadily" value="1">
      <label for="AcceptsAdv iceReadily">Acc epts advice readily</label>
      <BR>

      ......(and so on for all 120 questions)...

      <BR>
      <Center>
      &nbsp; <INPUT TYPE="submit" value="Submit" name="Action" />
      </FORM>
      <%
      On Error Resume Next
      If Request.Form("A ction") = "Submit" Then
      strFilePath = server.MapPath( "hgb_experiment .mdb")
      strConn = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & strFilePath


      conn.open strConn
      n1 = clng(Request.Fo rm("Roster"))

      n2 = Request.Form("I nstructor")

      n3 = Request.Form("S emester")

      n4 = Request.Form("G ender")

      n5 = clng(Request.Fo rm("Password") )


      p1 = cint(Request.Fo rm("1_AbleToGiv eOrders"))

      p2= cint(Request.Fo rm("2_Appreciat ive"))

      p3= cint(Request.Fo rm("3_Apologeti c"))

      p4= cint(Request.Fo rm("4_AbleToTak eCareOfSelf"))


      p5= cint(Request.Fo rm("5_AcceptsAd viceReadily"))

      ....(and so on)...


      conn.qInsertRec ord n1, n2, n3, n4, n5, p1, p2, p3, p4, p5
      Response.Write "Your record has been added"

      End If

      %>
      <! ----- FORM CLOSED ---- FORM CLOSED ---- />
      </CENTER>
      </BODY>
      </HTML>

      Comment

      • Bob Barrows [MVP]

        #4
        Re: Need Help. - Can't find my error

        Gaby wrote:
        Heres the simplified version of the code. I will only include the
        code showing five questions, when the real one has over 120.....
        Strip it down even more. We don't need to see any html. Just extract the
        code used to communicate with the database and show us that, along with the
        details of thetables involved in your queries (field names and datatypes)

        --
        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"


        Comment

        • Mike Brind

          #5
          Re: Need Help. - Can't find my error

          <%
          On Error Resume Next
          First thing to do Gaby, is to get rid of this line. If there are
          errors, this line is hiding them. Run the page without this, and see
          if you get an error message. If you do, and don't understand it, post
          it here, in full, together with the line that causes the error.

          --
          Mike Brind

          Comment

          • Mike Brind

            #6
            Re: Need Help. - Can't find my error


            Mike Brind wrote:
            <%
            On Error Resume Next
            >
            First thing to do Gaby, is to get rid of this line. If there are
            errors, this line is hiding them. Run the page without this, and see
            if you get an error message. If you do, and don't understand it, post
            it here, in full, together with the line that causes the error.
            >
            --
            Mike Brind
            Actually, I suspect the cause of the problem will be an error relating
            to clng or cint. Here's a section from your code:

            <%
            ....

            p1 = cint(Request.Fo rm("1_AbleToGiv eOrders"))
            p2= cint(Request.Fo rm("2_Appreciat ive"))
            p3= cint(Request.Fo rm("3_Apologeti c"))
            p4= cint(Request.Fo rm("4_AbleToTak eCareOfSelf"))
            ....

            %>

            If any of these are unchecked, they will evaluate to an empty string.
            You can't convert that to an int. That will raise an error.
            Consequently, when you get to the conn.qInsertRec ord line, none of the
            parameters are set.

            --
            Mike Brind

            Comment

            • Gaby

              #7
              Re: Need Help. - Can't find my error


              Mike Brind wrote:
              <%
              On Error Resume Next
              >
              First thing to do Gaby, is to get rid of this line. If there are
              errors, this line is hiding them. Run the page without this, and see
              if you get an error message. If you do, and don't understand it, post
              it here, in full, together with the line that causes the error.
              >
              --
              Mike Brind
              I dont get any errors. I just nocite that window when I refresh.

              Here is the query I run
              It is called: qInsertRecord
              Heres a short version. It just looks like:
              INSERT INTO Research ( Roster, Instructor, [Password],
              1_AbletoGiveOrd ers, 2_Appreciative )
              VALUES ([n1], [n2], [n5], [p1], [p2]);

              My table is called Research. and My Acess DB is called
              hgb_experiment. mdb

              Comment

              • Bob Barrows [MVP]

                #8
                Re: Need Help. - Can't find my error

                Gaby wrote:
                Mike Brind wrote:
                >><%
                >>On Error Resume Next
                >>
                >First thing to do Gaby, is to get rid of this line. If there are
                >errors, this line is hiding them. Run the page without this, and see
                >if you get an error message. If you do, and don't understand it,
                >post it here, in full, together with the line that causes the error.
                >>
                >--
                >Mike Brind
                >
                I dont get any errors. I just nocite that window when I refresh.
                >
                Here is the query I run
                It is called: qInsertRecord
                Heres a short version. It just looks like:
                INSERT INTO Research ( Roster, Instructor, [Password],
                1_AbletoGiveOrd ers, 2_Appreciative )
                VALUES ([n1], [n2], [n5], [p1], [p2]);
                >
                What are the datatypes of these fields? What is the significance of the
                parameter names?
                My table is called Research. and My Acess DB is called
                hgb_experiment. mdb
                OK, so when you test this query in Access, it works correctly, right? That
                means there's a problem running it from ASP. Create a small page to test it,
                like this:

                <%
                dim cn, ar(4)
                ar(0)=<hard-coded value appropriate for Roster>
                ar(1)=<hard-coded value appropriate for Instructor>
                ar(2)=<hard-coded value appropriate for Password>
                ar(3)=<hard-coded value appropriate for 1_AbletoGiveOrd ers>
                ar(4)=<hard-coded value appropriate for 2_Appreciative>
                set cn=createobject ("adodb.connect ion")
                cn.open "provider=micro soft.jet.oledb. 4.0;" & _
                "data source=" & server.mapppath ("hgb_experimen t.mdb")
                cn.qInsertRecor d ar(0),ar(1),ar( 2),ar(3),ar(4)
                cn.close:set cn=nothing
                %>


                Run this page. Do you get any errors? Open your database in Access and
                verify that the record got inserted. Did it? If so, then we know there's no
                problem running the query and the problem is elsewhere, most likely with how
                you are handling the data submitted via the form. Anways, try the above test
                and let us know the result.



                --
                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"


                Comment

                • Dave Anderson

                  #9
                  Re: Need Help. - Can't find my error

                  Gaby wrote:
                  Heres the simplified version of the code...
                  I have a few observations, some of which are unlikely to be the problem.
                  Nevertheless, I offer them:


                  01. <input type="checkbox" id="1_AbleToGiv eOrders"
                  name="1_AbleToG iveOrders" value="1">
                  <label for="AbleToGive Orders">Able to give orders</label>
                  Your FOR attribute value does not match your ID attribute value, in
                  violation of the HTML specification:


                  Furthermore, your ID attributes do not conform to the requirement that they
                  begin with a letter:


                  These are repeated with questions 2-5.


                  <INPUT TYPE="submit" value="Submit" name="Action" />
                  More of a warning than anything, but you might want to avoid using the name
                  "Action" here, as it can lead you into a troubleshooting nightmare if you
                  confuse form.Action with form.action.


                  On Error Resume Next
                  If you insist on using this, make sure to check the Err Object
                  (http://msdn.microsoft.com/library/en...f8082fdbfe.asp)
                  at strategic places:

                  conn.open strConn
                  If Err.Number 0 Then
                  Response.Write( "Problem connecting!")
                  ...
                  Err.Clear
                  End If


                  <input type="text" size="12" maxlength="6" name="roster"
                  id="roster" <--- I have taken this out of sequence
                  n1 = clng(Request.Fo rm("Roster"))
                  If you have not validated the contents of Request.Form("R oster").Item, then
                  CLng is prone to failure. Ditto for CInt further down.


                  conn.qInsertRec ord n1, n2, n3, n4, n5, p1, p2, p3, p4, p5
                  You never reached this point, IMO.



                  --
                  Dave Anderson

                  Unsolicited commercial email will be read at a cost of $500 per message. Use
                  of this email address implies consent to these terms.


                  Comment

                  • Gaby

                    #10
                    Re: Need Help. - Can't find my error

                    OK, so when you test this query in Access, it works correctly, right? That
                    means there's a problem running it from ASP. Create a small page to test it,
                    like this:
                    >
                    <%
                    dim cn, ar(4)
                    ar(0)=<hard-coded value appropriate for Roster>
                    ar(1)=<hard-coded value appropriate for Instructor>
                    ar(2)=<hard-coded value appropriate for Password>
                    ar(3)=<hard-coded value appropriate for 1_AbletoGiveOrd ers>
                    ar(4)=<hard-coded value appropriate for 2_Appreciative>
                    set cn=createobject ("adodb.connect ion")
                    cn.open "provider=micro soft.jet.oledb. 4.0;" & _
                    "data source=" & server.mapppath ("hgb_experimen t.mdb")
                    cn.qInsertRecor d ar(0),ar(1),ar( 2),ar(3),ar(4)
                    cn.close:set cn=nothing
                    %>
                    >
                    >
                    Run this page. Do you get any errors? Open your database in Access and
                    verify that the record got inserted. Did it? If so, then we know there's no
                    problem running the query and the problem is elsewhere, most likely with how
                    you are handling the data submitted via the form. Anways, try the above test
                    and let us know the result.
                    >
                    Since you are running the existing query I have do I have to change
                    that as well to include ar(0), ar(1), ect? also, should i put the hard
                    coded values in "" or not? Let me know so I can run the test page like
                    you say.

                    Thanks again everyone for the help.
                    Im really trying to get this done ASAP so I can begin experiments next
                    week.

                    Gabriel

                    Comment

                    • Bob Barrows [MVP]

                      #11
                      Re: Need Help. - Can't find my error

                      Gaby wrote:
                      >OK, so when you test this query in Access, it works correctly,
                      >right? That means there's a problem running it from ASP. Create a
                      >small page to test it, like this:
                      >>
                      ><%
                      >dim cn, ar(4)
                      >ar(0)=<hard-coded value appropriate for Roster>
                      >ar(1)=<hard-coded value appropriate for Instructor>
                      >ar(2)=<hard-coded value appropriate for Password>
                      >ar(3)=<hard-coded value appropriate for 1_AbletoGiveOrd ers>
                      >ar(4)=<hard-coded value appropriate for 2_Appreciative>
                      >set cn=createobject ("adodb.connect ion")
                      >cn.open "provider=micro soft.jet.oledb. 4.0;" & _
                      >"data source=" & server.mapppath ("hgb_experimen t.mdb")
                      >cn.qInsertReco rd ar(0),ar(1),ar( 2),ar(3),ar(4)
                      >cn.close:set cn=nothing
                      >%>
                      >>
                      >>
                      >Run this page. Do you get any errors? Open your database in Access
                      >and verify that the record got inserted. Did it? If so, then we know
                      >there's no problem running the query and the problem is elsewhere,
                      >most likely with how you are handling the data submitted via the
                      >form. Anways, try the above test and let us know the result.
                      >>
                      >
                      Since you are running the existing query I have do I have to change
                      that as well to include ar(0), ar(1), ect?
                      ?
                      No. Run it as is. This is intended to test the ability to pass values to
                      your parameterized query and run it without error.
                      also, should i put the hard
                      coded values in "" or not?
                      Of course! The next step after successfully testing this is to modify it to
                      accept data submitted from your form.

                      --
                      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"


                      Comment

                      • Gaby

                        #12
                        Re: Need Help. - Can't find my error

                        Bob,

                        <%
                        dim cn, ar(4)
                        ar(0)=<"2223344 44">
                        ar(1)=<"Norton" >
                        ar(2)=<"581371" >
                        ar(3)=<"3">
                        ar(4)=<"3">
                        set cn=createobject ("adodb.connect ion")
                        cn.open "provider=micro soft.jet.oledb. 4.0;" & _
                        "data source=" & server.mapppath ("hgb_experimen t.mdb")
                        cn.qInsertRecor d ar(0),ar(1),ar( 2),ar(3),ar(4)
                        cn.close:set cn=nothing
                        %>

                        Tested the page above and I got
                        Microsoft VBScript compilation error '800a03ea'

                        Syntax error

                        /web/test/hbrown/test.asp, line 4

                        ar(0)=<"2223344 44">
                        -------------------^

                        Comment

                        • Mike Brind

                          #13
                          Re: Need Help. - Can't find my error


                          Gaby wrote:
                          Mike Brind wrote:
                          <%
                          On Error Resume Next
                          First thing to do Gaby, is to get rid of this line. If there are
                          errors, this line is hiding them. Run the page without this, and see
                          if you get an error message. If you do, and don't understand it, post
                          it here, in full, together with the line that causes the error.

                          --
                          Mike Brind
                          >
                          I dont get any errors. I just nocite that window when I refresh.
                          >
                          Did you remove On Error Resume Next?

                          --
                          Mike Brind

                          Comment

                          • Gaby

                            #14
                            Re: Need Help. - Can't find my error

                            Did you remove On Error Resume Next?
                            >
                            --
                            Mike Brind
                            Yes I did. It made no difference. It went to the FormResponse page
                            but the info didnt go through.

                            Comment

                            • Bob Lehmann

                              #15
                              Re: Need Help. - Can't find my error

                              >ar(0)=<"222334 444">
                              You need to remove < & >.

                              ar(0)="22233444 4"

                              Bob Lehmann

                              "Gaby" <GabrielESandov al@gmail.comwro te in message
                              news:1153942759 .964049.245640@ m79g2000cwm.goo glegroups.com.. .
                              Bob,
                              >
                              <%
                              dim cn, ar(4)
                              ar(0)=<"2223344 44">
                              ar(1)=<"Norton" >
                              ar(2)=<"581371" >
                              ar(3)=<"3">
                              ar(4)=<"3">
                              set cn=createobject ("adodb.connect ion")
                              cn.open "provider=micro soft.jet.oledb. 4.0;" & _
                              "data source=" & server.mapppath ("hgb_experimen t.mdb")
                              cn.qInsertRecor d ar(0),ar(1),ar( 2),ar(3),ar(4)
                              cn.close:set cn=nothing
                              %>
                              >
                              Tested the page above and I got
                              Microsoft VBScript compilation error '800a03ea'
                              >
                              Syntax error
                              >
                              /web/test/hbrown/test.asp, line 4
                              >
                              ar(0)=<"2223344 44">
                              -------------------^
                              >

                              Comment

                              Working...