下面的代码是我之前用来从mdb里把ip库导出到mysql的代码
- <html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
-
</head>
-
<body>
-
<%
-
'连接数据库
-
Dim dbpath:dbpath="F:\province_isp_ip\province_isp_ip.mdb"
-
set conn_sign=server.createobject("adodb.connection")
-
conn_sign.open "driver={microsoft access driver (*.mdb)};dbq=" & dbpath
-
-
sql="select * from ip order by start_ip"
-
set rs=server.createobject("adodb.recordset")
-
'执行查询语句
-
rs.open sql,conn_sign,1,3
-
conn_sign.execute sql
-
Dim totalnum:totalnum=rs.recordcount
-
'输出总记录数
-
Response.Write "#total:"& totalnum & vbCrLf
-
-
'打开文件
-
-
Set fso = Server.CreateObject("Scripting.FileSystemObject")
-
ForReading = 1
-
ForWriting = 2
-
ForAppending = 8
-
set file = fso.opentextfile("F:\\ip.sql", ForAppending, TRUE)
-
-
'输出sql语句到sql文件中
-
file.write("insert into ip (start_ip,end_ip,province,isp,start_ip1,end_ip1) values " & vbCrLf)
-
do while not rs.eof
-
file.write("('" & rs("start_ip") & "','" & rs("end_ip") &"','" & rs("province") & "','"& rs("isp") & "','"& rs("start_ip1") & "','"& rs("end_ip1")&"'),"& vbCrLf)
-
rs.movenext
-
loop
-
rs.close
-
set rs = nothing
-
-
file.write(";")
-
file.close
-
set file = nothing
-
set fso = nothing
-
%>
-
</body>
-
</html>
阅读(3568) | 评论(0) | 转发(0) |