精美而实用的网站,关注web编程技术、网站运营、SEO推广,让您轻松愉快的学习

ASP检查指定表的指定字断中是否包含有某个值,支持模糊查找,这里用自定义函数来实现。函数作用:检测数据表中某个字段是否存在某个内容。

函数返回值:若不存在某内容返回false,存在返回true;

函数各个参数说明:

table:需要查找的数据库表名
fieldname:字段名称
fieldcontent:要查找的字段内容
isblur:是否需要模糊匹配,取值0或1

ASP模糊查询表中指定字段是否包含指定内容函数代码

Function CheckExist(table,fieldname,fieldcontent,isblur)
CheckExist=false
If isblur=1 Then
   set rsCheckExist=conn.execute("select * from "&table&" where "&fieldname&" like '%"&fieldcontent&"%'")
else
   set rsCheckExist=conn.execute("select * from "&table&" where "&fieldname&"= '"&fieldcontent&"'")
End if
  if not (rsCheckExist.eof and rsCheckExist.bof) then CheckExist=true
rsCheckExist.close
set rsCheckExist=nothing
End Function

青岛星网温馨提醒: 使用本函数前请先包含你的数据库连接文件。

Tags:ASP 模糊查询