Click to See Complete Forum and Search --> : Recordset If Problem


IxxI
08-01-2005, 10:51 AM
I'm dynamically creating an HTML page using fields from a database, one of my fields is for checkboxes/radioboxes, and can be either y (for display), n (for don't display) or c (for display checked). An example of this is:


strSQL = "SELECT row1, row2, row3, " & Request.QueryString("price") & "price, sect, " & Request.QueryString("show") & " FROM table WHERE row1 = 'thissect' AND (" & Request.QueryString("show") & " = 'y' OR " & Request.QueryString("show") & " = 'c')"


used with the if statement:


If objRS(5) = "c" Then
Response.Write("<td width='10%'><INPUT TYPE='RADIO' NAME='radio1' VALUE='" & objRS(0) & "' checked></td>")
Else
Response.Write("<td width='10%'><INPUT TYPE='RADIO' NAME='radio1' VALUE='" & objRS(0) & "'></td>")
End If


However in this case I get an error:


strSQL = "SELECT row1, row2, row3, " & Request.QueryString("price") & "price, row5, row6, row7, row8, row9 " & Request.QueryString("show") & " FROM table WHERE row1 = 'thatsect' AND (" & Request.QueryString("show") & " = 'y' OR " & Request.QueryString("show") & " = 'c')"


when I add the if statement:


If objRS(9) = "c" Then
Response.Write("<td width='10%'><INPUT TYPE='" & objRS(5) & "' NAME='" & objRS(6) & "' VALUE='" & objRS(7) & "' checked></td>")
Else
Response.Write("<td width='10%'><INPUT TYPE='" & objRS(5) & "' NAME='" & objRS(6) & "' VALUE='" & objRS(7) & "'></td>")
End If


It fails on the if statement - can anyone tell me why (names of rows/tables etc. have been changed to ease readability so any mistakes in these are not in my code).
Thanks in advance,
IxxI

IxxI
08-01-2005, 11:21 AM
Sorry found it at last - a comma between row9 and " & Request.QueryString("show") & " is missing. I'm having a stupid day...