Jump to content

Filtering a Recordset using checkboxes on page


Mixaalser684

Recommended Posts

I built a Card database and now I wan't to put it online using ASP and IIS. I build a page in dreamweaver, and created a relevant rsEdition (each card comes from specific edition). On page I've put rsEdition.txtEdition object and added a checkbox in front of it, and wrapped both in the repeat region and put them in frmEditionCheck, because there are 40 editions that needs to be displayed, and I've set int the database the default state for the checkbox is checked.The next step is to display all cards from the database, using rsCard.txtCardName object. I've put that also on the page and wrapped a reapeat region around it too. Now, all cards are displayed succesfully, but I want to be able to filter the rsCard by clicking on checkboxes for each edition. How do I do that?

Link to comment
Share on other sites

To make it easier here's the screen from the program of what I'm trying to build on my webpage:bazafilter.jpgAs far as my work goes on this matter I've sucessfully created with the help of dreamweaver a checkbox that when I click it updates itself, but when I add a reapeat region (inside the form around the Checkbox and txtEdition Name), and put only one update button in the form (ate the edn of the form outside repeat region) I'm getting this error message:

Error Type:ADODB.Field (0x800A0BCD)Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record./allmymtgcards/cards/index.asp, line 105
Now, if I add the repeat region on form itself everything works fine, but then I have a submit button for each record in tblEditions, and that's not the way I wan't things to be. I wan't to have only one submit button that will update all the checked or unchecked checkboxes, Can someone help me change the dreamweaver code to make this work? Here's my code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%><!--#include file="../Connections/connAllMyMTGCards.asp" --><%Dim MM_editActionMM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))If (Request.QueryString <> "") Then  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)End If' boolean to abort record editDim MM_abortEditMM_abortEdit = false%><%' IIf implementationFunction MM_IIf(condition, ifTrue, ifFalse)  If condition = "" Then	MM_IIf = ifFalse  Else	MM_IIf = ifTrue  End IfEnd Function%><%If (CStr(Request("MM_update")) = "form1") Then  If (Not MM_abortEdit) Then	' execute the update	Dim MM_editCmd	Set MM_editCmd = Server.CreateObject ("ADODB.Command")	MM_editCmd.ActiveConnection = MM_connAllMyMTGCards_STRING	MM_editCmd.CommandText = "UPDATE tblEdition SET bitEditionChecked = ? WHERE intEditionID = ?" 	MM_editCmd.Prepared = true	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.Form("bitEditionChecked"), 1, 0)) ' adDouble	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble	MM_editCmd.Execute	MM_editCmd.ActiveConnection.Close	' append the query string to the redirect URL	Dim MM_editRedirectUrl	MM_editRedirectUrl = "index.asp"	If (Request.QueryString <> "") Then	  If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then		MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString	  Else		MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString	  End If	End If	Response.Redirect(MM_editRedirectUrl)  End IfEnd If%><%Dim rsEditionDim rsEdition_cmdDim rsEdition_numRowsSet rsEdition_cmd = Server.CreateObject ("ADODB.Command")rsEdition_cmd.ActiveConnection = MM_connAllMyMTGCards_STRINGrsEdition_cmd.CommandText = "SELECT * FROM tblEdition" rsEdition_cmd.Prepared = trueSet rsEdition = rsEdition_cmd.ExecutersEdition_numRows = 0%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title></head><body><p> </p><form action="<%=MM_editAction%>" method="post" name="form1" id="form1">  <table>	<tr valign="baseline">	  <td><input type="checkbox" name="bitEditionChecked" value="1"  <%If (CStr(rsEdition.Fields.Item("bitEditionChecked").Value) = CStr("True")) Then Response.Write("checked='checked'") : Response.Write("")%> />	  <%=(rsEdition.Fields.Item("txtEdition").Value)%> </td>	</tr>	<tr valign="baseline">	  <td><input type="submit" value="Filter" />	  </td>	</tr>  </table>  <input type="hidden" name="MM_update" value="form1" />  <input type="hidden" name="MM_recordId" value="<%= rsEdition.Fields.Item("intEditionID").Value %>" /></form><p> </p></body></html><%rsEdition.Close()Set rsEdition = Nothing%>

Link to comment
Share on other sites

The EOF/BOF error means that there were no records in the recordset when you're trying to access a record. It says the error is on line 105 but the code you posted doesn't have 105 lines so I'm not sure why you are getting the error. I don't see anything looping or repeating so I'm not sure what to tell you.

Link to comment
Share on other sites

The EOF/BOF error means that there were no records in the recordset when you're trying to access a record. It says the error is on line 105 but the code you posted doesn't have 105 lines so I'm not sure why you are getting the error. I don't see anything looping or repeating so I'm not sure what to tell you.
The error message was form the first longer example. The one I've posted was shorter with only one table involved.Here's the second (alos short example with one table) with the same error message problem:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%><%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "h:/inetpub/wwwroot/db/allmymtgcards.mdb"%><%Dim MM_editActionMM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))If (Request.QueryString <> "") Then  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)End If' boolean to abort record editDim MM_abortEditMM_abortEdit = false%><%' IIf implementationFunction MM_IIf(condition, ifTrue, ifFalse)  If condition = "" Then	MM_IIf = ifFalse  Else	MM_IIf = ifTrue  End IfEnd Function%><%If (CStr(Request("MM_update")) = "form1") Then  If (Not MM_abortEdit) Then	' execute the update	Dim MM_editCmd	Set MM_editCmd = Server.CreateObject ("ADODB.Command")	MM_editCmd.ActiveConnection = conn	MM_editCmd.CommandText = "UPDATE tblColor SET bitColorChecked = ? WHERE intColorID = ?" 	MM_editCmd.Prepared = true	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.Form("bitColorChecked"), 1, 0)) ' adDouble	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble	MM_editCmd.Execute	MM_editCmd.ActiveConnection.Close	' append the query string to the redirect URL	Dim MM_editRedirectUrl	MM_editRedirectUrl = "dfault.asp"	If (Request.QueryString <> "") Then	  If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then		MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString	  Else		MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString	  End If	End If	Response.Redirect(MM_editRedirectUrl)  End IfEnd If%><%Dim rsDim rs_cmdDim rs_numRowsSet rs_cmd = Server.CreateObject ("ADODB.Command")rs_cmd.ActiveConnection = connrs_cmd.CommandText = "SELECT * FROM tblColor" rs_cmd.Prepared = trueSet rs = rs_cmd.Executers_numRows = 0%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title></head><body><form method="post" name="form1" id="form1"><%while rs.EOF=false%><p><input <%If (CStr(rs.Fields.Item("bitColorChecked").Value) = CStr("True")) Then Response.Write("checked=""checked""") : Response.Write("")%> name="bitColorChecked" type="checkbox" value="" /><%response.write(rs.fields.item("txtColor").value)		rs.MoveNext%></p>	<%wend%><input name="Submit" type="submit" value="Submit" /></form></body></html><%rs.closeconn.closeset rs = Nothingset conn = Nothing%>

And the error is the same (showing the right line this time):

Error Type:ADODB.Field (0x800A0BCD)Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record./allmymtgcards/index.asp, line 86
I understand what the error says but I don't know why it says that because there are 10 records in rs.Color (so it's obviously not empty). Here's what I've noticed that may be of any help. If I put the repeat region(while-wend) around the form, there are no error messages but I don't want to do it that way. I wan't to create the region inside the form, so that the amount of checkboxes for each record is repeated, but still only one submit button is left so when I submit the form it all the records are updated(states of checkboxes). That should be the example above, but it gives this error message. Can someone explain why and rewrite the code and post it and make this work? Thank you.
Link to comment
Share on other sites

Line 86 in that code is a blank line, is your line 86 this line:response.write(rs.fields.item("txtColor").value)or this line:rs.MoveNextIt doesn't make sense that it would not give an error if the form was included inside the while loop, but it does otherwise. The form tag is just text, a line of text isn't going to make any difference to what the ASP code is doing.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...