ASP检查指定表的指定字断中是否包含有某个值,支持模糊查找,这里用自定义函数来实现。函数作用:检测数据表中某个字段是否存在某个内容。
函数返回值:若不存在某内容返回false,存在返回true;
table:需要查找的数据库表名 fieldname:字段名称 fieldcontent:要查找的字段内容 isblur:是否需要模糊匹配,取值0或1
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
青岛星网温馨提醒: 使用本函数前请先包含你的数据库连接文件。