Results 1 to 15 of 15

Thread: Need help With this error.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    254

    Question Need help With this error.

    hi guys
    Recently i have been given a task to debug a website survey system. The problem is whenever user tried to submit there i will be a error saying
    No value give for one or more required parameter
    I am very very new to asp and in fact this is the first time i come in contact with asp. Was doing jsp previously this is for one of my final year project. Would apperciate if anyone could help

    This is the code....
    <%Option Explicit%>
    <!--#include file="includes/config.asp" -->
    <%
    dim conn, rs, strsql, x
    dim updateOK
    dim update_survey_status
    dim i
    dim array_result()



    set conn = server.CreateObject ("ADODB.Connection")
    conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("mentorDB.mdb")
    set rs = server.CreateObject ("ADODB.Recordset")

    strsql = "SELECT * FROM " & survey_result_table

    for i = 0 to 12
    redim preserve array_result(i)
    array_result(i) = "Q" & i+1
    next

    rs.open strsql, conn, 1

    strsql = "UPDATE [" & survey_result_table & "] SET "
    for i = lbound(array_result) to ubound(array_result)
    if i <> ubound(array_result) then
    strsql = strsql & array_result(i) & "='" & request.form(array_result(i)) & "',"
    elseif i = ubound(array_result) then
    strsql = strsql & array_result(i) & "='" & request.form(array_result(i)) & "'"
    end if
    next
    strsql = strsql & " WHERE ADM='" & Session("ParseAdm_No") & "'"

    on error resume next
    conn.execute strsql

    if err<>0 then 'if have errors
    updateOK = false

    response.write("<script language = 'javascript'> alert('" & err.Description & "'); </script>")


    else 'If no errors
    updateOK = true
    end if

    if updateOK = true then
    strsql = "UPDATE [" & left(trim(Session("ParsePem_Gpr")),2) & "] SET SURVEY_DONE=TRUE WHERE ADM='" & Session("ParseAdm_No") & "'"

    on error resume next
    conn.execute strsql

    if err<>0 then 'if have errors
    update_survey_status = false

    else 'If no errors
    update_survey_status = true
    end if
    end if

    rs.close
    conn.close
    set rs=nothing
    set conn=nothing

    if updateOK = true and update_survey_status = true then

    response.redirect("http://localhost/night/thanks.asp")

    elseif updateOK = false or update_survey_status = false then
    response.write("Update failed. Please contact administrator.")

    end if


    %>

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    what line does the error message say is causing the error?
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    254
    it didnt state, but i tried line by line shifting down the pop up of the error it should be at the first update function..... hope you can help and if theres anyway that i can show what line is the error pls let me know

  4. #4
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    test for errors after any piece of code that might fail, something like this:
    VB Code:
    1. <%Option Explicit%>
    2. <!--#include file="includes/config.asp" -->
    3. <%
    4. dim conn, rs, strsql, x
    5. dim updateOK
    6. dim update_survey_status
    7. dim i
    8. dim array_result()
    9.  
    10. On Error Resume Next
    11.  
    12. updateOk = true
    13. update_survey_status = true
    14.  
    15. set conn = server.CreateObject ("ADODB.Connection")
    16. conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("mentorDB.mdb")
    17. If Err.number <> 0 Then
    18.     Response.Write("Error opening connection...<br/>")
    19.     Response.Write("Error: " & Err.number & "<br/>" & "Desc: " + Err.Description)
    20.     Response.End
    21. End If
    22.  
    23.  
    24.  
    25. strsql = "SELECT * FROM " & survey_result_table
    26.  
    27. for i = 0 to 12
    28.     redim preserve array_result(i)
    29.     array_result(i) = "Q" & i+1
    30. next
    31.  
    32. set rs = server.CreateObject ("ADODB.Recordset")
    33. rs.open strsql, conn, 1
    34. If Err.number <> 0 Then
    35.     Response.Write("Error opening recordset...<br/>")
    36.     Response.Write("SQL: " & strsql & "<br/>")
    37.     Response.Write("Error: " & Err.number & "<br/>" & "Desc: " + Err.Description)
    38.     Response.End
    39. End If
    40.  
    41. strsql = "UPDATE [" & survey_result_table & "] SET "
    42. for i = lbound(array_result) to ubound(array_result)
    43.     if i <> ubound(array_result) then
    44.         strsql = strsql & array_result(i) & "='" & request.form(array_result(i)) & "',"
    45.     elseif i = ubound(array_result) then
    46.         strsql = strsql & array_result(i) & "='" & request.form(array_result(i)) & "'"
    47.     end if
    48. next
    49. strsql = strsql & " WHERE ADM='" & Session("ParseAdm_No") & "'"
    50.  
    51. conn.execute strsql
    52. If Err.number <> 0 Then
    53.     Response.Write("Error executing sql...<br/>")
    54.     Response.Write("SQL: " & strsql & "<br/>")
    55.     Response.Write("Error: " & Err.number & "<br/>" & "Desc: " + Err.Description)
    56.     Response.End
    57. End If
    58.  
    59. if updateOK = true then
    60.     strsql = "UPDATE [" & left(trim(Session("ParsePem_Gpr")),2) & "] SET SURVEY_DONE=TRUE WHERE ADM='" & Session("ParseAdm_No") & "'"
    61.  
    62.     conn.execute strsql
    63.     If Err.number <> 0 Then
    64.         Response.Write("Error executing sql...<br/>")
    65.         Response.Write("SQL: " & strsql & "<br/>")
    66.         Response.Write("Error: " & Err.number & "<br/>" & "Desc: " + Err.Description)
    67.         Response.End
    68.     End If
    69. end if
    70.  
    71. rs.close
    72. conn.close
    73. set rs=nothing
    74. set conn=nothing
    75.  
    76. if updateOK = true and update_survey_status = true then
    77.     response.redirect("http://localhost/night/thanks.asp")
    78. elseif updateOK = false or update_survey_status = false then
    79.     response.write("Update failed. Please contact administrator.")
    80. end if
    81.  
    82.  
    83. %>

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    254
    the error is still the same =( can anyone help ? and see if the coding is correct =)

  6. #6
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    that code wasn't supposed to fix anything, it was supposed to help you figure out where and maybe why the error is happening. Did you figure out at least where the error is occurring? if not, post the code you're using to figure out where the error is occurring.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    254
    It happen during the first update function...

    Akababy.Net... Life Redefined!

  8. #8
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    So did you print out the SQL and try to figure out why or if the sql is the problem?(it probably is the probem, you need to print that sql out to the screen or somewhere and see why it's the problem)

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    254
    um.. the error i get is No value give for one or more required parameter.. I wonder what that means

    Akababy.Net... Life Redefined!

  10. #10
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    post the sql it's trying to run.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    254
    strsql = "UPDATE [" & survey_result_table & "] SET "
    for i = lbound(array_result) to ubound(array_result)
    if i <> ubound(array_result) then
    strsql = strsql & array_result(i) & "='" & request.form(array_result(i)) & "',"
    elseif i = ubound(array_result) then
    strsql = strsql & array_result(i) & "='" & request.form(array_result(i)) & "'"
    end if
    next
    strsql = strsql & " WHERE ADM='" & Session("ParseAdm_No") & "'"

    on error resume next
    conn.execute strsql

    if err<>0 then 'if have errors
    updateOK = false

    Akababy.Net... Life Redefined!

  12. #12
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    That's the code that generates the sql, print out the actual SQL it's trying to run. so right after the line:
    VB Code:
    1. conn.execute strsql
    put this:
    VB Code:
    1. If Err.number <> 0 Then
    2.   Response.Write("Error: " & Err.number & "<br/>")
    3.   Response.Write("Desc: " & Err.description & "<br/>")
    4.   Response.Write("SQL:<br/>")
    5.   Response.Write(strsql)
    6.   Response.End
    7. End If
    and then post what the actual sql code is.

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    254
    ok got it


    Error: -2147217904
    Desc: No value given for one or more required parameters.
    SQL:
    UPDATE [Survey_Result] SET Q1='3',Q2='3',Q3='3',Q4='1',Q5='4',Q6='4',Q7='4',Q8='4',Q9='4',Q10='1',Q11='1',Q12='1',Q13='1' WHERE ADM='000577U'

    Akababy.Net... Life Redefined!

  14. #14
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    Can you run that query successfully against the database? maybe make sure there are columns Q1 through Q13 for that particular survey. I've seen some other posts where users experienced the same error message when they really had a type mismatch. After verifying that all of the columns exist(Q1 through Q13) check their datatypes. If they're numeric you're gonna wann take off the single ticks(apostraphe's) in your update, so it'd look something like:
    PHP Code:
    UPDATE Whatever SET Q1=3Q2=... 
    oh, and you don't do anything with that recordset rs, it's in this snippet:
    VB Code:
    1. strsql = "SELECT * FROM " & survey_result_table
    2.  
    3. for i = 0 to 12
    4.     redim preserve array_result(i)
    5.     array_result(i) = "Q" & i+1
    6. next
    7.  
    8. set rs = server.CreateObject ("ADODB.Recordset")
    9. rs.open strsql, conn, 1
    It doesn't appear to be used for anything, if that's true, get rid of it, just more moving pieces in the way of figuring out what's wrong(leave the for..next loop just get rid of the recordset part).

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    254
    ok.. thx alot.. =)

    Akababy.Net... Life Redefined!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width