C
clinttoris
Hello,
If someone could help me it would be appreciated as I am not having
much luck.
I'm struggling with my asp code and have some questions relating to asp
and oracle database.
First question. I have a web survey that I am working on and have
successfully dynamically taken the info from a database, displayed it
on the screen and then taken the users answers and inserted them into a
database table. Let me explain the problem now that you have the
background by showing my code.
Code:
<table width="60%" cellspacing="0" cellpadding="5">
<%
Do while not objRS.eof
response.write (objRS("Question_Id")& ". ")&(objRS("Descr")&
"<BR>") & "<BR>"
Do while not objTxt.eof
%>
<% If (objTxt("Type")) = "Radio" then %>
<input type="checkbox" name="questions"
value="<%=objTxt("sub_text")%>"> <%=(objTxt("Text")&"<BR>")%>
<input type="hidden" name="HiddenSurveyID"
value="<%=objRS("Survey_ID")%>">
<input type="hidden" name="HiddenQuestionID"
value="<%=objRS("Question_id")%>">
<input type="hidden" name="HiddenText"
value="<%=objTxt("text")%>">
<%ELSE%>
<br><%=(objTxt("Text"))%> <input type="text" size
="75" name="textBoxAnswer"
value=""> <BR>
<%End IF%>
<%
objTxt.movenext()
Loop
objRS.movenext()%>
<BR>
<%
Loop
%>
</table>
This is the main code that loops through each question from the
database and then displays the question and associated choices
underneath.
ie.How are you today
good(checkbox field)
Not bad(checkbox field)
excellent(checkbox field)
Other(Text box field)
The answers(ie.good, not bad etc) have values stored with a,b,c,d in
the database. When the user chooses good for instance I want the value
A to be written to the database and in another column in the database
the value GOOD. Instead it is writing A and then "good,not
bad,excellent,other". It is looping but have no idea how to just take
the value that they selected rather then inserting all the values. If
the whole structure of the loop needs to be changed please change it to
whatever you experts think is needed.
Secondly, how do I take the value of the text input field if other is
chosen for the associated question and then add D(or whatever value it
is) and the users text value(i.e what ever they fill in the text box).
So in the above example, if the user chooses other and writes in the
text box(horrible day, got into an accident), I want to insert into the
database d and "horrible day, got into an accident". Here is the code
that passes those values
Code:
<%
oConn.Open
Set oCmd = Server.CreateObject("ADODB.Command")
oCmd.ActiveConnection = oConn
oCmd.CommandType = 4
oCmd.CommandText = "surveyanswerinsert.surveyanswerinsert"
oCmd.Parameters.Append oCmd.CreateParameter("SurveyID", adVarChar,
adParamInput, 400, Request.Form("HiddenSurveyID"))
oCmd.Parameters.Append oCmd.CreateParameter("AnswerID", adVarChar,
adParamInput, 900, Request.Form("questions"))
oCmd.Parameters.Append oCmd.CreateParameter("Text", adVarChar,
adParamInput, 900, Request.Form("HiddenText"))
oCmd.Execute
%>
Lastly, as you can see with the above code you might be wondering why I
used adVarchar for SurveyID and AnswerID. Well I don't want to but if I
make the surveyID adNumeric and change the survey id field in the
database to Number and run this code on the web I get
Code:
Error Type:
ADODB.Command (0x800A0D5D)
Application uses a value of the wrong type for the current operation.
It only works with adVarchar. Could someone tell me what I am doing
wrong. It's oracle 9 and classic asp.
Thanks experts and sorry for all the questions.
If someone could help me it would be appreciated as I am not having
much luck.
I'm struggling with my asp code and have some questions relating to asp
and oracle database.
First question. I have a web survey that I am working on and have
successfully dynamically taken the info from a database, displayed it
on the screen and then taken the users answers and inserted them into a
database table. Let me explain the problem now that you have the
background by showing my code.
Code:
<table width="60%" cellspacing="0" cellpadding="5">
<%
Do while not objRS.eof
response.write (objRS("Question_Id")& ". ")&(objRS("Descr")&
"<BR>") & "<BR>"
Do while not objTxt.eof
%>
<% If (objTxt("Type")) = "Radio" then %>
<input type="checkbox" name="questions"
value="<%=objTxt("sub_text")%>"> <%=(objTxt("Text")&"<BR>")%>
<input type="hidden" name="HiddenSurveyID"
value="<%=objRS("Survey_ID")%>">
<input type="hidden" name="HiddenQuestionID"
value="<%=objRS("Question_id")%>">
<input type="hidden" name="HiddenText"
value="<%=objTxt("text")%>">
<%ELSE%>
<br><%=(objTxt("Text"))%> <input type="text" size
="75" name="textBoxAnswer"
value=""> <BR>
<%End IF%>
<%
objTxt.movenext()
Loop
objRS.movenext()%>
<BR>
<%
Loop
%>
</table>
This is the main code that loops through each question from the
database and then displays the question and associated choices
underneath.
ie.How are you today
good(checkbox field)
Not bad(checkbox field)
excellent(checkbox field)
Other(Text box field)
The answers(ie.good, not bad etc) have values stored with a,b,c,d in
the database. When the user chooses good for instance I want the value
A to be written to the database and in another column in the database
the value GOOD. Instead it is writing A and then "good,not
bad,excellent,other". It is looping but have no idea how to just take
the value that they selected rather then inserting all the values. If
the whole structure of the loop needs to be changed please change it to
whatever you experts think is needed.
Secondly, how do I take the value of the text input field if other is
chosen for the associated question and then add D(or whatever value it
is) and the users text value(i.e what ever they fill in the text box).
So in the above example, if the user chooses other and writes in the
text box(horrible day, got into an accident), I want to insert into the
database d and "horrible day, got into an accident". Here is the code
that passes those values
Code:
<%
oConn.Open
Set oCmd = Server.CreateObject("ADODB.Command")
oCmd.ActiveConnection = oConn
oCmd.CommandType = 4
oCmd.CommandText = "surveyanswerinsert.surveyanswerinsert"
oCmd.Parameters.Append oCmd.CreateParameter("SurveyID", adVarChar,
adParamInput, 400, Request.Form("HiddenSurveyID"))
oCmd.Parameters.Append oCmd.CreateParameter("AnswerID", adVarChar,
adParamInput, 900, Request.Form("questions"))
oCmd.Parameters.Append oCmd.CreateParameter("Text", adVarChar,
adParamInput, 900, Request.Form("HiddenText"))
oCmd.Execute
%>
Lastly, as you can see with the above code you might be wondering why I
used adVarchar for SurveyID and AnswerID. Well I don't want to but if I
make the surveyID adNumeric and change the survey id field in the
database to Number and run this code on the web I get
Code:
Error Type:
ADODB.Command (0x800A0D5D)
Application uses a value of the wrong type for the current operation.
It only works with adVarchar. Could someone tell me what I am doing
wrong. It's oracle 9 and classic asp.
Thanks experts and sorry for all the questions.