盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

结合asp与存储过程做的搜索程序

时间:2025/1/2作者:未知来源:盾怪网教程人气:

[摘要]") m_strDest = replace (m_strDest , "++" , "") call print ("[AnalyseK...
")
m_strDest = replace (m_strDest , "++" , "
")
call print ("[AnalyseKeyword()]:处理多个减号完毕后m_strDest = '" + m_strDest + "'")

'处理加号两边的空格
m_strDest = replace(m_strDest , " +" , "+")
m_strDest = replace(m_strDest , "+ " , "+")
m_strDest = replace(m_strDest , " + " , "+")
call print ("[AnalyseKeyword()]:处理减号两边的空格完毕后m_strDest = '" + m_strDest + "'")

'-------------------------------处理加号完毕-----------------------------

'-------------------------------处理多个减号及减号两边的空格问题-----------------------------


'处理多个减号的问题,遇到多个减号则认为是字符串,而不是逻辑符
m_strDest = replace (m_strDest , "---" ,"~~~")
m_strDest = replace (m_strDest , "--" , "~~")

call print ("[AnalyseKeyword()]:处理多个减号完毕后m_strDest = '" + m_strDest + "'")

'处理减号两边的空格
m_strDest = replace(m_strDest , " -" , "-")
m_strDest = replace(m_strDest , "- " , "-")
m_strDest = replace(m_strDest , " - " , "-")
call print ("[AnalyseKeyword()]:处理加号两边的空格完毕后m_strDest = '" + m_strDest + "'")

'-------------------------------处理减号完毕-----------------------------

'------------------------------处理字符串两头的加减号问题-----------------
if len(m_strDest) >= 3 then
m_strHead = left(m_strDest , 1)
m_strMiddle = mid(m_strDest , 2 , len(m_strDest) - 2)
m_strTail = right(m_strDest , 1)
if m_strHead = "+" or m_strHead = "-" then
m_strHead = ""
end if
if m_strTail = "+" or m_strTail = "-" then
m_strTail = ""
end if
m_strDest = m_strHead + m_strMiddle + m_strTail
end if
'----------------------------处理完毕-------------------------------------
m_strDest = replace(m_strDest , "--" , "~~")
m_strDest = replace(m_strDest , "++" , "
")
m_strDest = replace(m_strDest , chr(32) , "@")
AnalyseKeyword = m_strDest
call print ("[AnalyseKeyword()]:全部处理完毕后m_strDest = '" + m_strDest + "'")

end function
%>


存储过程
/*********************************************************************/
/* proc name : Up_ParseWordSearch */
/* */
/* Description: 关键字搜索 */
/* */
/* parameters: @a_strCategoryID 分类id */
/* @a_intPosition 调用的位置 */
/* @a_strParseWord 搜索关键字 */
/* @a_intRowCount 限定最多取得记录数 */
/* */
/* date: 2000/6/28 */
/* */
/* author: Liuyunpeng */
/* */
/* history: */
/*********************************************************************/

if exists (select * from sysobjects where id = object_id("up_ParseWordSearch"))
drop proc up_ParseWordSearch
go

create proc up_ParseWordSearch @a_strParseword varchar(255) ,
@a_strCategoryID varchar(255) ,
@a_intPosition tinyint ,
@a_intRowCount int
as
declare @m_strSqlCondition varchar(255) --Sql语句的条件部分
declare @m_strSqlSelect varchar(255) --Sql语句的选择部分
declare @m_strSqlCategory varchar(100) --sql语句的分类部分

/*根据调用位置决定sql的选择部分*/
select @m_strSqlSelect
= case
when @a_intPosition = 4 then --商品库
"select ProductID , 'Title' = ProductName , 'Description' = left(Description , 100) "
+ " from Product where "
when @a_intPosition = 5 then --商业机会库
"select ID , Title ,'Description' = left(convert(varchar,content) , 100) "
+ " from BusinessChance where "
when @a_intPosition = 6 then --公司库
"select CompanyID , 'Title' = CompanyName , 'Description' =left(Description , 100) "
+ " from Company where "
end

/*根据分类ID决定sql的分类部分*/
select @m_strSqlCategory
= case
when @a_strCategoryID <> "0" then " CategoryID like '" + @a_strCategoryID + "%' and "
else ""
end

/*根据调用位置决定sql的条件部分*/
select @m_strSqlCondition
= case
when @a_intPosition = 4 --商品
then "(ProductName like '%" + @a_strParseWord + "%'"
+ " or Description like '%" + @a_strParseWord + "%'"
+ " or ProducerName like '%" + @a_strParseWord + "%') "
when @a_intPosition = 5 --商业机会
then "(Title like '%" + @a_strParseWord + "%'"
+ " or Keyword like '%" + @a_strParseWord + "%') "
when @a_intPosition = 6
then "(CompanyName like '%" + @a_strParseWord + "%'"
+ " or Description '%" + @a_strParseWord + "%') "
end

set rowcount @a_intRowCount
exec (@m_strSqlSelect + @m_strSqlCategory + @m_strSqlCondition)
set rowcount 0
go
(出处:热点网络)

关键词:结合asp与存储过程做的搜索程序




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版