PDA

Click to See Complete Forum and Search --> : Need help With this error.


baby
Dec 16th, 2003, 02:14 AM
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


%>

Memnoch1207
Dec 16th, 2003, 08:29 AM
what line does the error message say is causing the error?

baby
Dec 16th, 2003, 08:47 AM
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

pvb
Dec 17th, 2003, 07:49 PM
test for errors after any piece of code that might fail, something like this:<%Option Explicit%>
<!--#include file="includes/config.asp" -->
<%
dim conn, rs, strsql, x
dim updateOK
dim update_survey_status
dim i
dim array_result()

On Error Resume Next

updateOk = true
update_survey_status = true

set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("mentorDB.mdb")
If Err.number <> 0 Then
Response.Write("Error opening connection...<br/>")
Response.Write("Error: " & Err.number & "<br/>" & "Desc: " + Err.Description)
Response.End
End If



strsql = "SELECT * FROM " & survey_result_table

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

set rs = server.CreateObject ("ADODB.Recordset")
rs.open strsql, conn, 1
If Err.number <> 0 Then
Response.Write("Error opening recordset...<br/>")
Response.Write("SQL: " & strsql & "<br/>")
Response.Write("Error: " & Err.number & "<br/>" & "Desc: " + Err.Description)
Response.End
End If

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") & "'"

conn.execute strsql
If Err.number <> 0 Then
Response.Write("Error executing sql...<br/>")
Response.Write("SQL: " & strsql & "<br/>")
Response.Write("Error: " & Err.number & "<br/>" & "Desc: " + Err.Description)
Response.End
End If

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

conn.execute strsql
If Err.number <> 0 Then
Response.Write("Error executing sql...<br/>")
Response.Write("SQL: " & strsql & "<br/>")
Response.Write("Error: " & Err.number & "<br/>" & "Desc: " + Err.Description)
Response.End
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


%>

baby
Dec 21st, 2003, 09:04 PM
the error is still the same =( can anyone help ? and see if the coding is correct =)

pvb
Dec 21st, 2003, 10:27 PM
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.

baby
Dec 21st, 2003, 11:24 PM
It happen during the first update function...

pvb
Dec 22nd, 2003, 08:29 AM
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)

baby
Dec 22nd, 2003, 08:34 AM
um.. the error i get is No value give for one or more required parameter.. I wonder what that means

pvb
Dec 22nd, 2003, 09:29 AM
post the sql it's trying to run.

baby
Dec 22nd, 2003, 09:32 AM
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

pvb
Dec 22nd, 2003, 09:48 AM
That's the code that generates the sql, print out the actual SQL it's trying to run. so right after the line:conn.execute strsql put this:
If Err.number <> 0 Then
Response.Write("Error: " & Err.number & "<br/>")
Response.Write("Desc: " & Err.description & "<br/>")
Response.Write("SQL:<br/>")
Response.Write(strsql)
Response.End
End If and then post what the actual sql code is.

baby
Dec 23rd, 2003, 10:23 PM
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'

pvb
Dec 23rd, 2003, 10:59 PM
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:
UPDATE Whatever SET Q1=3, Q2=4 ...
oh, and you don't do anything with that recordset rs, it's in this snippet:strsql = "SELECT * FROM " & survey_result_table

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

set rs = server.CreateObject ("ADODB.Recordset")
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).

baby
Dec 30th, 2003, 07:36 PM
ok.. thx alot.. =)