|
-
Dec 16th, 2003, 03:14 AM
#1
Thread Starter
Addicted Member
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
%>
-
Dec 16th, 2003, 09:29 AM
#2
Frenzied Member
what line does the error message say is causing the error?
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Dec 16th, 2003, 09:47 AM
#3
Thread Starter
Addicted Member
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
-
Dec 17th, 2003, 08:49 PM
#4
Hyperactive Member
test for errors after any piece of code that might fail, something like this:
VB Code:
<%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
%>
-
Dec 21st, 2003, 10:04 PM
#5
Thread Starter
Addicted Member
the error is still the same =( can anyone help ? and see if the coding is correct =)
-
Dec 21st, 2003, 11:27 PM
#6
Hyperactive Member
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.
-
Dec 22nd, 2003, 12:24 AM
#7
Thread Starter
Addicted Member
It happen during the first update function...

Akababy.Net... Life Redefined!
-
Dec 22nd, 2003, 09:29 AM
#8
Hyperactive Member
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)
-
Dec 22nd, 2003, 09:34 AM
#9
Thread Starter
Addicted Member
um.. the error i get is No value give for one or more required parameter.. I wonder what that means

Akababy.Net... Life Redefined!
-
Dec 22nd, 2003, 10:29 AM
#10
Hyperactive Member
post the sql it's trying to run.
-
Dec 22nd, 2003, 10:32 AM
#11
Thread Starter
Addicted Member
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!
-
Dec 22nd, 2003, 10:48 AM
#12
Hyperactive Member
That's the code that generates the sql, print out the actual SQL it's trying to run. so right after the line: put this:
VB Code:
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.
-
Dec 23rd, 2003, 11:23 PM
#13
Thread Starter
Addicted Member
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!
-
Dec 23rd, 2003, 11:59 PM
#14
Hyperactive Member
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=3, Q2=4 ...
oh, and you don't do anything with that recordset rs, it's in this snippet:
VB Code:
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).
-
Dec 30th, 2003, 08:36 PM
#15
Thread Starter
Addicted Member

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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|