当前位置:编程学习 > VB >>

对存入数据库的IP进行查询,怎么查询不到记录

<!--#include file="../conn3.asp"-->
<%
action=request("action")
if action="" then 
%>
<FIELDSET align=center>
            <LEGEND>IP段查询</LEGEND>
            <form action="" method="post" name="form1" id="form1">
  <div align="center">
            <table width="730" border="0">
              <tr>
                <td width="131" height="18" align="center">开始IP:</td>
                <td width="589"><label></label>
                  <input name="a0" type="text" id="Excelname" value="0" size="4" />
                  <label>
                  <input name="a1" type="text" value="0" size="4">
                  <input name="a2" type="text" value="0" size="4">
                  <input name="a3" type="text" value="0" size="4">
                  </label></td>
              </tr>
  <tr>
                <td width="131" height="18" align="center">结束IP:</td>
                <td width="589"><label></label>
                  <input name="b1" type="text" id="Excelname" value="255" size="4" />
                  <input name="b2" type="text" value="255" size="4">
                  <input name="b3" type="text" value="255" size="4">
                  <input name="b4" type="text" value="255" size="4"></td>
              </tr>
              <tr>
                <td height="23"><label>带*的内容必须填写</label><input name="action" type="hidden" value="1"></td>
                <td><label>
                                 <input type="submit" name="Submit" value="查询" />
                                 <input name="reset" type="reset"  value="重置" />
                </label></td>
              </tr>
            </table>
</div>
</form>
            <P></P></FIELDSET>
<% else %>
<%
dim a(3),b(3)
for i=0 to 3
astr="a"&i
a(i)=request(astr)
next
for i=0 to 3
bstr="b"&i
b(i)=request(bstr)
next
SQL="select IP_Address,count(IP_Address) as num from Address_IP group by IP_Address order by count(IP_Address)"
SET CustomerList=conn.EXECUTE(SQL)
%> 

<FONT SIZE="5"><center>数据库记录</center></FONT>
<CENTER>
<TABLE BORDER=1>
<tr> 
<td>具体地址</td>
<td>IP地址</td>
<td>次数</td>
</tr>
<% 
IPname=""
DO WHILE NOT CustomerList.EOF
IP=CustomerList("IP_Address")
count1=CustomerList("num")
IPnum=split(IP,".")
j=0
nIP=""
nIPnum=""
for i=0 to 3
j=j+1
if cint(IPnum(i))>cint(a(i)) and cint(IPnum(i))<cint(b(i)) then 
nIP=IP
ncount=count1   
exit for
elseif cint(IPnum(i))<cint(a(i)) or cint(IPnum(i))>cint(b(i)) then exit for
end if
next
%>
<%
if nIP<>"" and ncount<>"" then
sql="select * from IPname where IPaddress='"&nIP&"'"
set rs=conn.execute(sql)
if not rs.EOF then
IPname=rs("IPname")
else
IPname="未知"
end if
%> 
<TR>
<TD><% =IPname %></TD>
<TD><% =nIP%></TD>
<TD><% =ncount%></TD>
</TR>
<%
end if
if j=4 then
if cint(IPnum(3))=cint(a(3)) or cint(IPnum(3))=cint(b(3)) then
sql="select * from IPname where IPaddress='"&IP&"'"
set rs=conn.execute(sql)
if not rs.EOF then
IPname=rs("IPname")
else
IPname="未知"
end if
response.write(j)
%> 
<TR>

<TD><% =IPname %></TD>
<TD><% =IP%></TD>
<TD><% =CustomerList("num") %></TD>
</TR>
<%
end if
end if
CustomerList.movenext 
loop
%>
 
</TABLE>
</CENTER>
<%
end if 
%> 
如果把这块红色
 elseif cint(IPnum(i))<cint(a(i)) or cint(IPnum(i))>cint(b(i)) then
换成
 elseif cint(IPnum(i))<cint(a(i)) and cint(IPnum(i))>cint(b(i)) then
可以查询,但是测试结果会出错
请看看我上面的代码的问题
补充:VB ,  网络编程
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,