私は古典的なASPの文字列検索用のコードを書いていますが、エラーが表示されます。例えば 検索エラーが発生する "下付き文字範囲外のエラー" aspの古典
my name is lucky from earth
に書き込みされている場合、私は
のMicrosoft VBScriptランタイムエラー範囲のうち '800a0009'
: 線68は、ライン68
添字このエラーが出ます: '6'
/bdn6/prod_search.asp
SWord = SWord & " " & Trim(arrKeyWords(j))
は私のコードは以下のように与えられる:
<%
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)
%>
は、この問題を解決するために私を助けてください。