472,811 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 software developers and data experts.

Really need help ASAP with ASP, looping, inserting from database SP

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"))%>&nbsp;&nbsp;<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.

Jun 6 '06 #1
2 4629
>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.
Stop using checkboxes, use a radio button. Unless you really mant to
select more than one. And the selected item's value is the VALUE
assigned in the radio button that gets checked. if you want
additional info in a new field, you have to do an IF/THEN on the
value, something like:

IF VALUE="A" THEN DATA="Chevy"

Insert that into the database in your SQL INSERT statement.
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
Again, learn to use forms. The same process is used, but if the
VALUE="D" THEN DATA = TextBoxValue.
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.


That's a "Well, duh.." kind of statement. You can't use a letter in a
numeric field. Nothing wrong with VARCHAR except that if the field
length is always 1 (A, B, C, etc...) then it's not really VAR is it?
Just a CHAR with a length of 1.

Note that you'l need to use whatever Oracle has, I've used SQL Server
for so long I almost forgot how to spell "Oracle".

Jeff
Jun 7 '06 #2

Jeff Cochran wrote:
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.


Stop using checkboxes, use a radio button. Unless you really mant to
select more than one. And the selected item's value is the VALUE
assigned in the radio button that gets checked. if you want
additional info in a new field, you have to do an IF/THEN on the
value, something like:

IF VALUE="A" THEN DATA="Chevy"

Insert that into the database in your SQL INSERT statement.
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


Again, learn to use forms. The same process is used, but if the
VALUE="D" THEN DATA = TextBoxValue.
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.


That's a "Well, duh.." kind of statement. You can't use a letter in a
numeric field. Nothing wrong with VARCHAR except that if the field
length is always 1 (A, B, C, etc...) then it's not really VAR is it?
Just a CHAR with a length of 1.

Note that you'l need to use whatever Oracle has, I've used SQL Server
for so long I almost forgot how to spell "Oracle".

Jeff


Jeff thanks for getting back to me.

O.k I wish I could use any of the info you provided but I cannot as it
doesn't apply.
As for using the radio buttons. This will not work as I need to select
multiple values. My questions usually end with select all that apply?
So using radio buttons will not work and that is why I am using check
boxes. Any ideas how to construct my loop or just take the values the
user selects from my checkboxes as posted in my original question?

Secondly I know how to use forms but if my loop is not constructed
properly my passing of data will be affected so therefore I will not be
able to capture the proper text. So your answer will not be sufficient
either.

Thirdly, the surveyID and answerID is not getting passed a letter it
is getting passed a number. So your statement Well, duh.." kind of
statement is incorrect as you are mistaken as to what value was being
passed. I'm assuming because my loop and hidden fields are not working
correctly the value 1,1,1,1 is being passed as a string so the
AdNumeric will not function. But I need someone to first fix my loop
using the required checkboxes needed. Thanks for your replies Jeff and
wish I could use anything you said but unfortunately I cannot.

Also, I wish I could use SQL server which I have over the past 7 yrs
unfortunately my new company is using Oracle. Ya that Sucks:(

Any other ideas?

Jun 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ryan Wagner | last post by:
I am doing many SQL insert statements to insert records into an oracle database. I need the order of the records, after inserting all records, to be the same as the order I inserted them in. Right...
2
by: Ivo | last post by:
Hi, I have an audio file (.mid or .wav or .mp3) in an object element: <object id="snd" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"...
2
by: Jeffrey D Moncrieff | last post by:
I am trying to create a data base for colleting date for my research project. I have run in to a couple of problems and I need it fast ASAP I need it to be able to add data and edit them and view...
1
by: Scott Chapman | last post by:
I am working with Python (psycopg). I have HTML with embedded Python that I'm inserting into a database and it could contain any character. Single quotes, at least, must be escaped (to two...
1
by: Arda Han | last post by:
Hi friends, I need a sample application for inserting,updating,deleting database rows. In this example I want learn creating MDI applications. Inserting,Deleting,Editing database rows on...
2
by: altergothen | last post by:
Hi there I am a newbie to ASP.Net - Please Help! I am trying to insert the values of my variables into a database. If I try the following it works perfectly: string insertQuery = "INSERT into...
1
by: Massimo Bonanni | last post by:
Hi, I try to implement ASAP protocol in my web service, but I find a very hard problem. I define my SOAP Header: public class Request : SoapHeader {
9
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but...
6
by: Bunty | last post by:
I want to insert values in the database.If i insert values one by one then it works till 4 or 5 fields then after it gives error.In my database there are more than 20 field.Pls help me.
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.