为什么调用数据库就不行?

下面是乔治老师的代码,一切正常。

<%
Dim aa, ipList, ip, found
aa = Request.ServerVariables("REMOTE_ADDR")

ipList = Array("99.88", "110.52", "43.80.235", "11.9.67.180")
found = False

For Each ip In ipList
    If InStr(aa, ip) > 0 Then
        found = True
        Exit For
    End If
Next

If found Then
    Response.Write "ok"
    Response.End
End If
%>

但是为什么调用数据库就不行?
ipList = Array(""&Rs("ip")&"")
Rs("ip") 输出就是这样:"99.88", "110.52", "43.80.235", "11.9.67.180"

我只想 ipList = Array(这里从数据库调用)
请问应该怎样写?

数据库的内容是这样的:
99.88, 110.52, 43.80.235, 11.9.67.180

也可以是这样的:
"99.88", "110.52", "43.80.235", "11.9.67.180"

只要哪种能用就可以。谢谢。

阅读 1.6k
1 个回答
<%
Dim aa, ipList, ip, found, dbIPList
aa = Request.ServerVariables("REMOTE_ADDR")

dbIPList = Rs("ip")

ipList = Split(dbIPList, ",")

found = False

For Each ip In ipList
    ip = Trim(ip)
    If InStr(aa, ip) > 0 Then
        found = True
        Exit For
    End If
Next

If found Then
    Response.Write "ok"
    Response.End
End If
%>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题