请问ASP有没有类似SQL 里 in 这样的运算符?

来源:百度知道 编辑:UC知道 时间:2024/07/01 04:16:27
请问ASP有没有类似SQL里in这样的运算符?
因为像下面这样太麻烦了
If rs("IP")="a" Or rs("IP")="b" Or rs("IP")="c" Or rs("IP")="d" Then
内容
End If
要是有像SQL里in(Select * From XX Where AA In ('a','b','c','d'))这样的效果就好了

你都写出来了还问什么?你写的非常正确
rs.open "Select * From XX Where AA In ('a','b','c','d')",conn,1,1
if not rs.eof then
内容
end if

本来就有好吧。instr()

ASP 没有类似的函数
但我们可以变通一下...
如:
if inStr("a;b;c;",rs("IP"))>0 then
....
end if

以上 功能 是有安全性BUG的...也就是说...当要查找的字符串里包含有分隔符(以上使用;)就有可能有问题.所以我们可以再变通一下..
function In(arr,str)
In = false
if isArray(arr) then
for i=0 to ubound(arr) step 1
if arr(i)=str then
In=true:exit for
end if
next
end if
end function

if In(split("a;b;c",";"),rs("IP")) then
.....
end if
使用split函数只是为了快速生成一个数组..

AscNum = asc(rs("IP"))

'a:97 d:100

if AscNum >=97 and AscNum <=100 then

end if