Click to See Complete Forum and Search --> : how to organize select/updates


marchnw
01-16-2008, 03:38 PM
I'm having a little difficulty. I need this page to get info from the db to fill in 20 groups of radio buttons on my page. If there is no row in the table with the current iAsmtID, then it should insert one(I can only have one row per iAsmtID). The user needs to be able to update their responses at a later time. This is running the update query when the page loads. Thus I fill out the radios and click submit, it comes up with the page without any radios filled in. If I click refesh it shows the correct values. If I click submit twice, it gives all the questions for that iAsmtID a value of zero. At the bottom is one of the groups of radios if it helps. All help appreciated. Thanks.


iAsmtID = Clng(request.QueryString("iAsmtID"))

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open My_Conn
set rs = Server.CreateObject("ADODB.Recordset")
str="SELECT * FROM ITCC_Test WHERE iAsmtID="&iAsmtID
'response.Write(str)
rs.open str, conn, adLockReadOnly
if rs.eof = true then
str = "INSERT INTO ITCC_Test (iAsmtID) VALUES ("&iAsmtID&")"
else
q1 = rs("q1")
q2 = rs("q2")
q3 = rs("q3")
q4 = rs("q4")
q5 = rs("q5")
q6 = rs("q6")
q7 = rs("q7")
q8 = rs("q8")
q9 = rs("q9")
q10 = rs("q10")
q11 = rs("q11")
q12 = rs("q12")
q13 = rs("q13")
q14 = rs("q14")
q15 = rs("q15")
q16 = rs("q16")
q17 = rs("q17")
q18 = rs("q18")
q19 = rs("q19")
q20 = rs("q20")
end if
rs.close
set rs = nothing

str = "UPDATE ITCC_Test SET q1 = "&cint(request.Form("q1"))&",q2 = "&cint(request.Form("q2"))&",q3 = "&cint(request.Form("q3"))&",q4 = "&cint(request.Form("q4"))&",q5 = "&cint(request.Form("q5"))&",q6 = "&cint(request.Form("q6"))&",q7 = "&cint(request.Form("q7"))&",q8 = "&cint(request.Form("q8"))&",q9 = "&cint(request.Form("q9"))&",q10 = "&cint(request.Form("q10"))&",q11 = "&cint(request.Form("q11"))&",q12 = "&cint(request.Form("q12"))&",q13 = "&cint(request.Form("q13"))&",q14 = "&cint(request.Form("q14"))&",q15 = "&cint(request.Form("q15"))&",q16 = "&cint(request.Form("q16"))&",q17 = "&cint(request.Form("q17"))&",q18 = "&cint(request.Form("q18"))&",q19 = "&cint(request.Form("q19"))&",q20 = "&cint(request.Form("q20"))&" WHERE iAsmtID=" & iAsmtID
conn.execute(str)

Conn.close
set Conn=nothing


:confused:



<tr>
<th><div align="left">2. Caregivers encourage children to notice when their peers are expressing emotion.</div></th>
<td>Y&nbsp;<input type="radio" name="q2" value=<%if q2 = 1 then %> "1" checked="true" <% else%> "1" <% end if%>/></td>
<td>N&nbsp;<input type="radio" name="q2" value=<%if q2 = 2 then %> "2" checked="true" <% else%> "2" <% end if%> onclick="return NewWindow_2()" /></td>
</tr>