欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時間:2007年07月21日 00:00:00   作者:  
純真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),點擊解壓

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

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

第四步:導(dǎo)入文本向?qū)В?
      1、選擇[帶分隔符-用逗號或制表符之類的符號分隔每個字段]選項
      2、下一步:選擇空格作為分隔符;
      3、下一步:新表中;
      4、下一步:第一字段,不做任何修改,默認(rèn)下一步;
      5、下一步:定義主鍵:選擇不要主鍵;
      6、下一步:默認(rèn)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導(dǎo)入。^!^

以后的應(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 
%> 
 

相關(guān)文章

最新評論