ASP实现智能搜索实现代码

2018-09-06 12:48

阅读:554

  <%
FunctionAutoKey(strKey)

ConstlngSubKey=2
lngLenKey=Len(strKey)

SelectCaselngLenKey
Case0若为空串,转到出错页
Response.RedirectError.htm
Case1若长度为1,则不设任何值
strNew1=
strNew2=
CaseElse若长度大于1,则从字符串首字符开始,循环取长度为2的子字符串作为查询条件

Fori=1TolngLenKey-(lngSubKey-1)

strSubKey=Mid(strKey,i,lngSubKey)

strNew1=strNew1&OrU_Namelike%&strSubKey&%
strNew2=strNew2&OrU_Infolike%&strSubKey&%
Next
EndSelect

得到完整的SQL语句
AutoKey=Select*fromT_SamplewhereU_Namelike%&strKey&%OrU_Infolike%&strKey&%&strNew1&strNew2
EndFunction
%>


评论


亲,登录后才可以留言!