leeny
02-15-2005, 10:07 PM
i get an error when I'm trying to display multiple records from a database by selecting from the checkbox.
If Request("Go")="Go" then
i = request.form("item")
Dim strSelection,arrSelection
strSelection = request.form("opt")
'convert strSelection to String
strSelection = CStr(strSelection)
arrSelection = Split(strSelection, ", ")'return array of sub strings
Dim i, strQuery
strQuery = "Select * from ABSSubGrade WHERE"
For i = 0 to UBOUND(arrSelection)
If i > 0 Then
strQuery = StrQuery & " OR Item = '" & arrSelection(i) & "' ORDER by Item,ABSID"
Else
strQuery = strQuery & " Item = '" & arrSelection(i) & "'"
End if
Next
sql31 = "Select * from ABS order by ABSID"
Set Rs31 = Server.CreateObject("ADODB.RecordSet")
Rs31.open sql31,conn
Set Rs32 = Server.CreateObject("ADODB.RecordSet")
'Rs32.open strQuery,conn
Response.write strQuery
%>
This works fine when i select two checkboxes, however when i select more than two, error occurs. please assis me.
i printed my sql statement and this is how it looks:
Select * from ABSSubGrade WHERE Item = 'S501 G10' OR Item = 'S501 G30' ORDER by Item,ABSID OR Item = 'S505 G10' ORDER by Item,ABSID
If Request("Go")="Go" then
i = request.form("item")
Dim strSelection,arrSelection
strSelection = request.form("opt")
'convert strSelection to String
strSelection = CStr(strSelection)
arrSelection = Split(strSelection, ", ")'return array of sub strings
Dim i, strQuery
strQuery = "Select * from ABSSubGrade WHERE"
For i = 0 to UBOUND(arrSelection)
If i > 0 Then
strQuery = StrQuery & " OR Item = '" & arrSelection(i) & "' ORDER by Item,ABSID"
Else
strQuery = strQuery & " Item = '" & arrSelection(i) & "'"
End if
Next
sql31 = "Select * from ABS order by ABSID"
Set Rs31 = Server.CreateObject("ADODB.RecordSet")
Rs31.open sql31,conn
Set Rs32 = Server.CreateObject("ADODB.RecordSet")
'Rs32.open strQuery,conn
Response.write strQuery
%>
This works fine when i select two checkboxes, however when i select more than two, error occurs. please assis me.
i printed my sql statement and this is how it looks:
Select * from ABSSubGrade WHERE Item = 'S501 G10' OR Item = 'S501 G30' ORDER by Item,ABSID OR Item = 'S505 G10' ORDER by Item,ABSID