實現純真IP txt轉mdb資料庫的方法

2022-09-29 05:00:07 字數 3012 閱讀 7450

純真ip資料庫轉動網資料庫asp指令碼

「**公升級」,就可以公升級ip資料庫到最新的版本,無需再到******新版的ip資料庫。

同時查詢程式(showip.exe)還提供了解壓為.txt檔案的功能:)

我們就借助這一功能實現轉mdb格式的資料庫。

第一步:開啟查詢程式(showip.exe),點選解壓

第二步:儲存匯出的資料文字為ipaddress.txt,提示成功後,確定關閉。

第三步:新建乙個mdb檔案,命名為ipaddress.mdb,點選開啟,使用access提供的匯入文字檔案的功能,把剛才匯出的ipaddress.txt匯入到資料庫中。

第四步:匯入文字嚮導:

1、選擇[帶分隔符-用逗號或製表符之類的符號分隔每個字段]選項

2、下一步:選擇空格作為分隔符;

&nbs程式設計客棧p;   3、下一步:新錶中;

4、下一步:第一字段,不做任何修改,預設下一步;

5、下一步:定義主鍵:選擇不要主鍵;

6、下一步:預設ipaddress表名,完成。

第五步:建立動網格式的資料表ipaddress2

id      自動編號(可以不要)

bbpzxnyz ip1     雙精度資料

&nbbpzxnyzbsp;ip2     雙精度資料

country 文字 100位元組

city    文字 255位元組

關閉資料庫。

第六步:在asp環境下執行ip.asp

第七步:此時的資料庫非常大,為了能夠小一些:(,建立乙個新的空資料庫,把原資料庫中ipadress2匯入。^!^

以後的應用我就不說了。~~~  

重要的指令碼部分: 

複製** **如下:

server.scripttimeout=999 

min=0 ''開始數 

max=260262''結束數 資料數量-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("資料庫連線出錯,請檢查連線字串程式設計客棧sp;1px solid threedshadow;position:absolute;top:expression((document.body.offsetheight-100)/2);left:expression((document.body.offsetwidth-400)/2);"">《程式設計客棧td align=""center"">資料庫連線出錯,請檢查連線字串

") 

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(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&"

endip:"&endip&"

country:"&country&"

local:"&local&"

"  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 "公升級成功!" 

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 

%> 

本文標題: 實現純真ip txt轉mdb資料庫的方法

本文位址:

無聊到轉純真IP資料庫為MDB

那天 想在網上做個位址 統計,找了半天發現沒有現成的,就用純真資料庫來轉,首先解成txt的文字有20m 然後以空格分割匯入excel 首先是ip 轉數字,然後是 地區部分由於有空格被分成了n多個字段。自帶函式沒有辦法,所以就開始寫巨集 如下 當然這個已經是改了幾次了,這個是可以正常執行的了,但是36...

ArcSDE轉本地MDB資料庫

乙個轉換類,將arcsde上特定要素資料集轉到本地的mdb中 using system using system.collections.generic using system.io using system.threading using esri.arcgis.geodatabase usin...

PHP利用純真IP資料庫在本地實現IP位址資訊查詢

準備工作 正面這個ip位址查詢處理的類 ip 地理位置查詢類 class helper iplocation 析構函式,用於在頁面執行結束後自動關閉開啟的檔案。public function destruct this fp 0 返回讀取的長整型數 access private return int...