佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > 實現(xiàn)純真IP txt轉(zhuǎn)mdb數(shù)據(jù)庫的方法

實現(xiàn)純真IP txt轉(zhuǎn)mdb數(shù)據(jù)庫的方法

熱門標簽:阿里云 Linux服務(wù)器 銀行業(yè)務(wù) 科大訊飛語音識別系統(tǒng) Mysql連接數(shù)設(shè)置 團購網(wǎng)站 電子圍欄 服務(wù)器配置
純真ip數(shù)據(jù)庫轉(zhuǎn)動網(wǎng)數(shù)據(jù)庫ASP腳本

去純真網(wǎng)站上下載ip數(shù)據(jù)庫,同時隨數(shù)據(jù)庫附送的查詢程序(Showip.exe)具有在線檢測并升級IP數(shù)據(jù)庫的功能,只要運行該程序,點擊右上角的
“在線升級”,就可以升級IP數(shù)據(jù)庫到最新的版本,無需再到下載網(wǎng)站下載新版的IP數(shù)據(jù)庫。

同時查詢程序(Showip.exe)還提供了解壓為.txt文件的功能:)
我們就借助這一功能實現(xiàn)轉(zhuǎn)MDB格式的數(shù)據(jù)庫。

第一步:打開查詢程序(Showip.exe),點擊解壓

第二步:保存導出的數(shù)據(jù)文本為ipaddress.txt,提示成功后,確定關(guān)閉。

第三步:新建一個MDB文件,命名為ipaddress.mdb,點擊打開,使用Access提供的導入文本文件的功能,把剛才導出的ipaddress.txt導入到數(shù)據(jù)庫中。

第四步:導入文本向?qū)В?
      1、選擇[帶分隔符-用逗號或制表符之類的符號分隔每個字段]選項
      2、下一步:選擇空格作為分隔符;
      3、下一步:新表中;
      4、下一步:第一字段,不做任何修改,默認下一步;
      5、下一步:定義主鍵:選擇不要主鍵;
      6、下一步:默認ipaddress表名,完成。

第五步:建立動網(wǎng)格式的數(shù)據(jù)表ipaddress2

        id      自動編號(可以不要)
        ip1     雙精度數(shù)據(jù)
        ip2     雙精度數(shù)據(jù)
        country 文本 100字節(jié)
        city    文本 255字節(jié)
關(guān)閉數(shù)據(jù)庫。

第六步:在ASP環(huán)境下運行ip.ASP

第七步:此時的數(shù)據(jù)庫非常大,為了能夠小一些:(,建立一個新的空數(shù)據(jù)庫,把原數(shù)據(jù)庫中ipadress2導入。^!^

以后的應(yīng)用我就不說了。~~~  

重要的腳本部分: 

復(fù)制代碼 代碼如下:


Server.ScriptTimeOut=999 
min=0 ''開始數(shù) 
max=260262''結(jié)束數(shù) 數(shù)據(jù)數(shù)量-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("head>meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"" />title>數(shù)據(jù)庫連接出錯,請檢查連接字串/title>/head>body>div align=""center"" style=""width:400px;height:100px;padding: 8px;font-size:9pt;border: 1px solid ThreeDShadow;POSITION:absolute;top:expression((document.body.offsetHeight-100)/2);left:expression((document.body.offsetWidth-400)/2);"">table width=""100%"" height=""100%"" style=""font-size:12px;font-family:Tahoma;"">tr>td align=""center"">strong>數(shù)據(jù)庫連接出錯,請檢查連接字串/strong>/td>/tr>/table>/div>/body>") 
 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"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 "升級成功!" 
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 
%> 
 

標簽:萍鄉(xiāng) 江蘇 廣元 大理 棗莊 衢州 衡水 蚌埠

巨人網(wǎng)絡(luò)通訊聲明:本文標題《實現(xiàn)純真IP txt轉(zhuǎn)mdb數(shù)據(jù)庫的方法》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    洞口县| 肥西县| 佛学| 托克逊县| 盐山县| 辽阳市| 元朗区| 安阳县| 沧州市| 万安县| 曲靖市| 嫩江县| 布拖县| 安国市| 舞阳县| 韩城市| 邯郸县| 祁门县| 焦作市| 大方县| 申扎县| 宜兰市| 沙河市| 辽阳市| 新晃| 昌乐县| 潜江市| 保德县| 宜宾县| 佛山市| 扶余县| 朝阳区| 万州区| 饶阳县| 合川市| 延安市| 宜阳县| 马公市| 奎屯市| 宁陕县| 贡嘎县|