<% Option Explicit ' START CONFIGURATION Dim connstr,prefix connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Database\MSAccess\Test.mdb;User Id=admin;Password=;" prefix = "ip" ' END CONFIGURATION Function Locate(ip,tblnam) Dim b,ipnum,con,rs,country If IsEmpty(Application.Contents(prefix & ip)) Then b = Split(ip,".") ipnum = b(0)*256.0*256.0*256.0 + b(1)*256.0*256.0 + b(2)*256.0 + b(3) Set con = Server.CreateObject("ADODB.Connection") con.Open connstr Set rs = Server.CreateObject("ADODB.Recordset") rs.Open "SELECT country FROM " & tblnam & " WHERE ip1 < " & ipnum & " AND " & ipnum & " < ip2",con If rs.BOF Or rs.EOF Then country = "??" Else country = rs("country") End If Set rs = Nothing Set con = Nothing Application.Contents(prefix & ip) = country Else country = Application.Contents(prefix & ip) End If Locate = country End Function %>