asp显示数据库里的前三位IP

来源:百度知道 编辑:UC知道 时间:2024/06/28 02:43:04
我将IP写入了数据库,显示的时候我只想让它显示前三位,请问代码怎么写?如:192.168.1.*
谢谢!
下面的IP地址从数据库里怎么调出
<%
str="192.168.1.1"
response.write left(str,InstrRev(str,"."))&"*"
%>

str="192.168.1.123"
response.write left(str,InstrRev(str,"."))&"*"

取出来,对字符串进行操作

数据库方式
select substring(ip,0,len(ip)-CHARINDEX('.',REVERSE(ip),0) + 1) + '.*' from 表

string s =ip.tostring().substring(0,10)+"*"

二楼的踩云追鱼说得对啊!我顶