派克钢笔和万宝龙钢笔:InStr取值问题,好心的大哥看看。

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/13 20:13:43
<%if InStr(trim(rs("V_People")),"|"&session("name")&"|")=0 then%>
<script language="javascript">
alert("你已经投过票了,谢谢你的投票")
history.back()
</script>
<%
response.End()
end if
%>
我发现,怎么点都是提示"你已经投过票了,谢谢你的投票"
但我数据库里面这个值是|

The InStr function returns the following values:

If InStr returns
string1 is zero-length 0
string1 is Null Null
string2 is zero-length start
string2 is Null Null
string2 is not found 0
string2 is found within string1 Position at which match is found
start > Len(string2) 0

所以阁下应该用显式的判断
if InStr(trim(rs("V_People")),"|"&session("name")&"|")=1

0 是找不到。

阁下逻辑错了。