WEB开发网
开发学院WEB开发ASP VBS 纯真IP数据库转MDB/MSSQL/MySQL 阅读

VBS 纯真IP数据库转MDB/MSSQL/MySQL

 2009-05-06 10:40:00 来源:WEB开发网   
核心提示:Function Mappath(n) Mappath=fso.getabsolutepathname(n)End FunctionFunction ipToNum(Ip) IpNs=split(ip,".") IpN=IpNs(0)*S4+IpNs(1)*S3+IpNs(2)*S2+IpNs

Function Mappath(n)
   Mappath=fso.getabsolutepathname(n)
End Function

Function ipToNum(Ip)
   IpNs=split(ip,".")
   IpN=IpNs(0)*S4+IpNs(1)*S3+IpNs(2)*S2+IpNs(3)*S1
   if err<>0 then IpN=0
   err.clear
   IpToNum=IpN
End Function

S1=256
S2=256*S1
S3=256*S2
S4=256*S3
on error resume next
Set Fso=CreateObject("Scripting.FileSystemObject")
Set Conn=CreateObject("ADODB.Connection")
Conn.open "PRovider=microsoft.jet.oledb.4.0;data source="&Mappath("dat.mdb")

Set Rs=CreateObject("ADODB.Recordset")
Rs.open "S elect * from d",Conn,2,3

Set Fto=Fso.OpenTextFile(Mappath("dat.txt"))
Do while not Fto.atendofstream
   Rs.addnew
   Res=Split(Replace(Replace(Fto.Readline,"   ",""),"  "," ")," ")
   Rs("s")=IpToNum(Res(0))
   Rs("e")=IpToNum(Res(1))
   Rs("c")=Res(2)
   Rs("h")=Res(3)
   Wscript.Echo "From "&Res(0)&" To "&Res(1)&" Updated."
   Rs.update
Loop
Rs.close


注意S elect中间有空格,复制时候请去掉中间空格。复制代码,保存另存为.vbs 即可。

将纯真数据库转MSSQL数据库也很简单,只需改

 程序代码
Conn.open “driver={SQL Server}; server=(local);database= ;uid= ;pwd= ”


将纯真数据库转MySQL数据库,只需改

 程序代码
Conn.open “Driver={mysql};database=[yourdatabase];uid=[username];pwd=[yourpassWord];option=16386;”

Tags:VBS 纯真 IP

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接