Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run sql update based on values selected

Status
Not open for further replies.

pandapark

Technical User
Jan 29, 2003
92
GB
Hi

I have a form based on a table Membership
There are 2 fields in the table bitApproved and bitDeclined.
I want 2 radio buttons, Approve and Reject, the user being able to choose one or the other for each record displayed.
The user can then run an update button, which looks for any values of 1 or 2 and performs a SQL update statement.
I have the following but
a) approve and reject can't be selected for each row - just once overall
b) the submit button is working but not running the SQL statement

thanks
ian


sqlstmt = "Select * from Membership where MB_GROUP = 10"
If Request.QueryString("order") <> "" Then
sqlstmt = sqlstmt & " ORDER BY " & Request.QueryString("order")
End If

Set objRS = objCon1.Execute (sqlstmt)

b = b & "<table border='1'>"
b = b & "<BR>"
b = b & "<td bgcolor=""#C0C0C0"" WIDTH=""13%""><font color=""#CC0000"" size=""2"" face=""Arial""><a href=""main.asp?page=540&order=MB_ID""><font color=""#003399""><B>ID</a></B></font></FONT></td>"
b = b & "<td bgcolor=""#C0C0C0"" WIDTH=""18%""><font color=""#CC0000"" size=""2"" face=""Arial""><a href=""main.asp?page=540&order=MB_MEMBER""><font color=""#003399""><B>Organisation Name</B></font></FONT></td>"
b = b & "<td bgcolor=""#C0C0C0"" WIDTH=""54%""><font color=""#CC0000"" size=""2"" face=""Arial""><a href=""main.asp?page=540&order=MB_EXTRA""><font color=""#003399""><B>Organisation Type</a></B></font></FONT></td>"
b = b & "<td bgcolor=""#C0C0C0"" WIDTH=""15%""><font color=""#CC0000"" size=""2"" face=""Arial""><a href=""main.asp?page=540&order=MB_EMAIL""><font color=""#003399""><B>Email Address</B></font></FONT></td>"
b = b & "<td bgcolor=""#C0C0C0"" WIDTH=""15%""><font color=""#CC0000"" size=""2"" face=""Arial""><a href=""main.asp?page=540&order=MB_ADDR1""><font color=""#003399""><B>Address</B></font></FONT></td>"
b = b & "<td bgcolor=""#C0C0C0"" WIDTH=""15%""><font color=""#CC0000"" size=""2"" face=""Arial""><font color=""#003399""><B>Approve</B></font></FONT></td>"
b = b & "<td bgcolor=""#C0C0C0"" WIDTH=""15%""><font color=""#CC0000"" size=""2"" face=""Arial""><font color=""#003399""><B>Reject</B></font></FONT></td>"
b = b & "</tr>"

While Not ObjRS.EOF


b = b & "<FORM METHOD=""POST"" ACTION=""main.asp?page=540"">"
b = b & "<tr>"
b = b & "<td><a href=""main.asp?page=540&MB_ID=" & ObjRS("MB_ID") & """><font color=""000099"">" & ObjRS("MB_ID") & "</a></td>"
b = b & "<td>" & OBjrs("MB_MEMBER") & "</td>"
b = b & "<td>" & ObjRS("MB_EXTRA") & "</td>"
b = b & "<td>" & ObjRs("MB_EMAIL") & "</td>"
b = b & "<td>" & ObjRs("MB_Addr1") & "</td>"
b = b & "<TD><input type=""radio"" name=""rdbutton"" value=""1""><br>"
b = b & "<TD><input type=""radio"" name=""rdbutton"" value=""2""><br></tD></TD>"
b = b & "</tr>"
RowCount = RowCount + 1
ObjRS.MoveNext
wend


b = b & "</table>"
b = b & "<TD><TR><div align=""center""><center><p><input type=""submit"" name=""cmdAction"" VALUE=""Approve""></p></tr></TD>"
b = b & "</FORM>"

if Request.Form("cmdAction") = "Approve" then
if request.form("rdbutton") = 1 then
sqlupdate = "UPDATE membership set bitApproved = true where MB_ID = " & MB_ID & " "
response.write sqlupdate
elseif request.form("rdbutton") = 2 then
sqlupdate = "UPDATE membership set bitDeclined = true where MB_ID = " & MB_ID & " "
elseif request.form("rdbutton") = "" then
end if
objCon1.execute (sqlupdate)
end if

Set objRS = Nothing
Set objRS1 = Nothing
Set objCon = Nothing
Set objCon1 = Nothing

 
try:
response.write request.form("rdbutton")

what does it output???

Known is handfull, Unknown is worldfull
 
also in this block :
if Request.Form("cmdAction") = "Approve" then
if request.form("rdbutton") = 1 then
sqlupdate = "UPDATE membership set bitApproved = true where MB_ID = " & MB_ID & " "
response.write sqlupdate
elseif request.form("rdbutton") = 2 then
sqlupdate = "UPDATE membership set bitDeclined = true where MB_ID = " & MB_ID & " "
elseif request.form("rdbutton") = "" then
end if
objCon1.execute (sqlupdate)
end if

you dont have a default value or a value check against sqlupdate to ensure you dont try to exec an empty variable. this might cause you problems later, if not already

[thumbsup2]DreX
aKa - Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top