checkboxes and other form inserts into a database

M

MrHelpMe

Hello experts,

I need a hand. On my asp submit page I have the following code:
Code:
for i = 1 to 5 ' 5 question form'

Question = Request.Form("Q" & i)
Answer = Request.Form("A" & i)
Comment  = Request.Form("C" & i )

ValComment = Replace(Comment, "'", "''")
ValAnswer = Replace(Answer, "'", "''")

checkbox = Request.Form("check")
checkbox = Split(checkbox,", ")
-----------------------------------------------------------------------------------------
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "removed for security reasons"
set sSQL = server.CreateObject ("ADODB.Recordset")
set sSQL1 = server.CreateObject ("ADODB.Recordset")
--------------------------------------------------------------------------------------------
IF........somthing here in the checkbox = STRUGGLING HERE please help
sSQL = "INSERT into Table (ID, Question, Answer, Comments, TimeStamp,
UserID)"
sSQL = sSQL &  "VALUES (Test_seq.nextval, '" & Question &"', '" &
checkbox &"', '" & ValComment &"', sysdate, '"& User & "')"

Else
sSQL1 = "INSERT into table (ID, Question, Answer, Comments, TimeStamp,
UserID)"
sSQL1 = sSQL1 &  "VALUES (Test_seq.nextval, '" & Question &"', '" &
ValAnswer &"', '" & ValComment &"', sysdate, '"& User & "')"
response.write ssql1 & "<BR>"
End IF
Next
response.end

Note: just the bulk of the code has been added so that you get an idea
of what it is that I am talking about.

On my html form I have a combination of dropdownlists and combo
boxes. The checkboxes all have the same name. It is basically 1
question checkbox with the ability to choose 5 answers. I have a
total of 5 questions(1 checkbox question and 3 drop downs and 1
textbox. What I am struggling with is how do I get the answers from
the checkboxes into the database as well as the other form elements.
If it is much easier to not parse the comma separated list then so be
it:) Thanks everyone.
 
T

ThatsIT.net.au

MrHelpMe said:
Hello experts,

I need a hand. On my asp submit page I have the following code:
Code:
for i = 1 to 5 ' 5 question form'

Question = Request.Form("Q" & i)
Answer = Request.Form("A" & i)
Comment  = Request.Form("C" & i )

ValComment = Replace(Comment, "'", "''")
ValAnswer = Replace(Answer, "'", "''")

checkbox = Request.Form("check")
checkbox = Split(checkbox,", ")
-----------------------------------------------------------------------------------------
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "removed for security reasons"
set sSQL = server.CreateObject ("ADODB.Recordset")
set sSQL1 = server.CreateObject ("ADODB.Recordset")[/QUOTE]

if checkbox(0) = correct answer then

[QUOTE]
sSQL = "INSERT into Table (ID, Question, Answer, Comments, TimeStamp,
UserID)"
sSQL = sSQL &  "VALUES (Test_seq.nextval, '" & Question &"', '" &
checkbox &"', '" & ValComment &"', sysdate, '"& User & "')"[/QUOTE]

you have set sSQL to be a recordset. now you are treating it as a string.


a recordset is for reading from a database, not for writting to it.

you need somthing like this

sql = "your sql statement"

cn.open "your connection string"
cn.execute(sql)
cn.close




[QUOTE]
Else
sSQL1 = "INSERT into table (ID, Question, Answer, Comments, TimeStamp,
UserID)"
sSQL1 = sSQL1 &  "VALUES (Test_seq.nextval, '" & Question &"', '" &
ValAnswer &"', '" & ValComment &"', sysdate, '"& User & "')"
response.write ssql1 & "<BR>"
End IF
Next
response.end

Note: just the bulk of the code has been added so that you get an idea
of what it is that I am talking about.

On my html form I have a combination of dropdownlists and combo
boxes. The checkboxes all have the same name. It is basically 1
question checkbox with the ability to choose 5 answers. I have a
total of 5 questions(1 checkbox question and 3 drop downs and 1
textbox. What I am struggling with is how do I get the answers from
the checkboxes into the database as well as the other form elements.
If it is much easier to not parse the comma separated list then so be
it:) Thanks everyone.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top