Realization of pure IP txt to MDB database method _ Application Skills

Source: Internet
Author: User
Tags mdb database
Pure IP Database Rotation Network database ASP script

Go to the pure website download IP database, at the same time with the database of the query program (Showip.exe) with online detection and upgrade the IP database function, as long as the program, click on the upper right corner of the
"Online Upgrade", you can upgrade the IP database to the latest version, no need to download the Web site to download the new version of the IP database.

The query Program (Showip.exe) also provides the ability to understand the compression of a. txt file:
We can use this function to implement the database in MDB format.

The first step: Open the Query Program (Showip.exe), click Decompression

Step Two: Save the exported data text as Ipaddress.txt, prompt after success, OK close.

Step three: Create a new MDB file named Ipaddress.mdb, click Open, and use the function of the import text file provided by access to import the ipaddress.txt that you just exported into the database.

Fourth Step: Import Text Wizard:
1. Select [delimited-Separate each field with symbols such as commas or tabs] option
2, Next: Select the space as a separator;
3, Next: the new table;
4, Next: The first field, do not make any changes, the default next step;
5, Next: The definition of primary key: Choose not to primary key;
6, Next: The default IPAddress table name, completed.

Fifth step: Establish the data table IPAddress2 of moving network format

ID Auto Number (can not)
IP1 Double Precision Data
IP2 Double Precision Data
Country Text 100 bytes
City Text 255 bytes
Closes the database.

Sixth step: Run ip.asp in ASP environment

Seventh step: At this time the database is very large, in order to be able to a little bit: (, create a new empty database, the original database Ipadress2 import.) ^!^

I will not say it later. ~~~

Important Scripting part:

Copy Code code as follows:

<%
server.scripttimeout=999
Min=0 ' ' Start number
max=260262 ' End number of data-1
Dim Conn
Set conn= Server.CreateObject ("ADODB.") Connection ")
Conn.connectionstring= "Provider=Microsoft.Jet.OLEDB.4.0; Jet oledb:database password=01;data source= "& Server.MapPath (" Ipaddress.mdb ")
Conn.Open
If ERR Then
Err.Clear
Set Conn = Nothing
Response.Write ("Response.End
End If

Set Rs=conn.execute ("SELECT * from [IPAddress]")

If not rs.eof then

First=rs. GetRows ()

For J=0 to 261501

Z= ""
Local= ""

For I=0 to 16
If Len (i,j) >0 Then
Z=first (i,j) & "$$" &z
End If
Next

Zz=split (Z, "$$")
STARTIP=ENADDR (ZZ (UBound (ZZ)-1))
ENDIP=ENADDR (ZZ (UBound (ZZ)-2))
Country=zz (UBound (ZZ)-3)
For zzz=0 to UBound (ZZ)-4
Local=zz (ZZZ) & "" &local
Next
Local=replace (Local, "'", "" ")
' Response.Write ' StartIP: "&startip&" <br>endip: "&endip&" <br>country: "&country & "<br>local:" &local& "<br><br>"
Conn.execute ("INSERT into [IPAddress2] (ip1,ip2,country,[city]) VALUES (" &startip& "," &endip& "," " &country& "', '" &local& ")"
Next
End If
Conn.execute ("Update [IPADDRESS2] set [city]="--' WHERE [city]= ' CZ88.] NET ' ")
Response.Write "Upgrade Successful! "
function enaddr (SIP)
ESIP=CSTR (SIP)
Str1=left (Sip,cint (InStr (SIP, ".") -1))
Sip=mid (Sip,cint (InStr (SIP, ".")) +1)
Str2=left (Sip,cint (InStr (SIP, ".")) -1)
Sip=mid (Sip,cint (InStr (SIP, ".")) +1)
Str3=left (Sip,cint (InStr (SIP, ".")) -1)
Str4=mid (Sip,cint (InStr (SIP, ".")) +1)
Enaddr=cint (STR1) *256*256*256+cint (str2) *256*256+cint (STR3) *256+cint (STR4)-1
End Function
%>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.