Ich schreibe Code für String-Suche in klassischen asp, aber es zeigen Fehler. Zum Beispiel ist, wennbekomme Fehler "Index außerhalb des Bereichs Fehler" in ASP classic
my name is lucky from earth
Ich erhalte diesen Fehler
Microsoft VBScript-Laufzeitfehler '800a0009'
Index außerhalb des zulässigen Bereichs auf der Suche schreiben: '6'
/bdn6/prod_search.asp 68, Zeile
wo Leitung 68 ist:
SWord = SWord & " " & Trim(arrKeyWords(j))
mein Code wie unten angegeben:
<%
Dim SearchWord, arrKeyWords, arrQry, MainQty, FinalQty, MergeQry, WhereCon, Cnt, tsearch, i, j
SearchWord = trim(request("searcha"))
arrKeyWords = Split(SearchWord ," ")
Cnt = Ubound(arrKeyWords) + 1
%>
<%
dim Qry, SWord, NLWord, TableName, LastIndex
MainQty = "select a.rProd_name, r_id "
TableName = "from reseller_prod a, brand e, V_brand f, V_modal g Where a.rprod_vbrand=f.Vb_Id and f.vb_active=0 and a.rprod_vmodel=g.Vm_id and g.Vm_active=0 and a.rProd_brand=e.Brand_id and e.brand_active=0 and a.rProd_price <> 0 and a.rProd_price is not Null and a.rprod_nowallowd=0 and a.r_id in(select s_usrid from Reseller where S_approval=0) and a.r_id in(select usr_id from usr where Usr_Active=0)"
NLWord = ""
For i = 0 To Cnt
SWord = ""
For j = 0 To ((Cnt) - i)
SWord = SWord & " " & Trim(arrKeyWords(j)) 'getting error on this line: Subscript out of range
Next
WhereCon = WhereCon & " And (a.rProd_name like '%" & Trim(SWord) & "%' or f.vb_name like '%" & Trim(SWord) & "%' or g.Vm_modal like '%" & Trim(SWord) & "%')"
Qry = MainQty & ", " & (i + 1) & " as SortRecord " & TableName & " " & WhereCon
LastIndex = i + 1
Qry = Qry & NLWord
NLWord = NLWord & " And (a.rProd_name not like '%" & Trim(SWord) & "%' And f.vb_name not like '%" & Trim(SWord) & "%' And g.Vm_modal not like '%" & Trim(SWord) & "%')"
FinalQty = FinalQty & Qry & " UNION "
WhereCon = ""
Qry = ""
Next
FinalQty = left(FinalQty, (Len(FinalQty) - 6))
MergeQry = FinalQty
FinalQty = ""
MainQty = "select a.Prod_name, '' as r_id "
TableName = "from product a, brand e, V_brand f, V_modal g Where a.prod_vbrand=f.Vb_Id and f.vb_active=0 and a.prod_vmodel=g.Vm_id and g.Vm_active=0 and a.Prod_brand=e.Brand_id and e.brand_active=0 and a.prod_active=0 and a.Prod_price <> 0 and a.Prod_price is not Null"
NLWord = ""
For i = 0 To Cnt
SWord = ""
For j = 0 To ((Cnt) - i)
SWord = SWord & " " & Trim(arrKeyWords(j))
Next
WhereCon = WhereCon & " And (a.Prod_name like '%" & Trim(SWord) & "%' or a.prod_keyword like '%" & Trim(SWord) & "%' or f.vb_name like '%" & Trim(SWord) & "%' or g.Vm_modal like '%" & Trim(SWord) & "%')"
Qry = MainQty & ", " & (LastIndex + i + 1) & " as SortRecord " & TableName & " " & WhereCon
Qry = Qry & NLWord
NLWord = NLWord & " And (a.Prod_name not like '%" & Trim(SWord) & "%' and a.prod_keyword not like '%" & Trim(SWord) & "%' And f.vb_name not like '%" & Trim(SWord) & "%' And g.Vm_modal not like '%" & Trim(SWord) & "%')"
FinalQty = FinalQty & Qry & " UNION "
WhereCon = ""
Qry = ""
Next
FinalQty = left(FinalQty, (Len(FinalQty) - 6))
FinalQty = FinalQty & "Order By SortRecord"
MergeQry = MergeQry & " UNION " & FinalQty
response.Write(MergeQry)
%>
Bitte helfen Sie mir, dieses Problem zu lösen.