How to convert pure IP txt to mdb database

Source: Internet
Author: User
Tags mdb database

Pure ip database turn Network Database ASP script

Download the IP data library from the pure real network. The query program (showip.exe) provided with the data library can detect and upgrade the IP database online. To run the program, click
"Online upgrade" allows you to upgrade the IP database to the latest version, without the need to download the new version of the IP database from the download website.

At the same time, the query program (showip.exe.pdf also provided the function to decompress the file into a. txt file :)
We can use this function to convert the database to the MDB format.

Step 1: Open the query program (showip.exe) and click Extract

Step 2: Save the exported data as ipaddress.txt. After the prompt is successful, close it.

Step 3: import the notebook to the database.

Step 4: import the text Wizard:
1. Select the [delimiter-separate each field with a comma or a Tab character] Option.
2. Next Step: Select space as the separator;
3. Next Step: Create a new table;
4. Next Step: do not modify the first field. The next step is used by default;
5. Next Step: Define the primary key: select not to use the primary key;
6. Next step: the default ipaddress table name is complete.

Step 5: create a data table in the dynamic network format ipaddress2

Id automatic number (optional)
Ip1 dual-precision data
Ip2 dual-precision data
Country text 100 bytes
City text 255 bytes
Shut down the database.

Step 6: Run ip. ASP in ASP environment

Step 7: The database is very large at this time. In order to be smaller: (create a new empty database and import ipadress2 from the original database. ^! ^

I will not talk about future applications .~~~

Important scripts:

Copy codeThe Code is as follows: <%
Server. ScriptTimeOut = 999
Min = 0'' start count
Max = 260262 ''end Data Count-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 rsw.conn.exe cute ("select * from [ipaddress]")

If not rs. eof then

First = rs. GetRows ()

For j = 0-261501

Z = ""
Local = ""

For I = 0 to 16
If len (first (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>"
Conn.exe cute ("insert into [ipaddress2] (ip1, ip2, country, [city]) values (" & startip & "," & endip &", '"& country &"', '"& local &"')")
Next
End if
Conn.exe cute ("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.