Access数据安全迁移到SQLite3[asp代码]
<%
Response.codepage = 65001
Response.charset = "utf-8"
'数据库连接
'A conn.open="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\a.mdb“
'B conn.open="DRIVER={SQLite3 ODBC Driver};DATABASE=D:\SQLITE\WWWW"
Server.ScriptTimeout = 500
Set conns = Server.CreateObject("ADODB.Connection")
Set rss = Server.CreateObject("ADODB.RecordSet")
conns.open "DRIVER={SQLite3 ODBC Driver};Database="&Server.MapPath("tt.db")
Set conna = Server.CreateObject("ADODB.Connection")
Set rsa = Server.CreateObject("ADODB.RecordSet")
conna.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db2-Ok.mdb")
ids = ""
id = ""
rsa.open "select * from Info order by ID asc",conna,3,1
rss.open "select * from Info",conns,1,3
If rss.eof Then
Do While Not rsa.eof
rss.addnew
rss("tid") = rsa("tid")
rss("xg") = rsa("xg")
rss("Title") = rsa("Title")
rss("Content") = rsa("Content")
rss("Author") = rsa("User")
rss("From") = rsa("From")
rss("hits") = rsa("hits")
If rsa("istj") = "True" Then
rss("istj") = 1
Else
rss("istj") = 0
End If
If rsa("isshow") = "True" Then
rss("isshow") = 1
Else
rss("isshow") = 0
End If
rss("isDel") = 0
rss("colorID") = 1
rss("addtime") = rsa("addtime")
'rss("tmpid") = rsa("ID")
rss.Update
rsa.movenext
Loop
End If
rsa.Close
rss.Close
Response.Write("Info导入成功")
Set rsa = Nothing
Set rss = Nothing
conna.close()
conns.close()
Set conna = Nothing
Set conns = Nothing
%>
上面的只是示例,本人曾经用过,还算不错,之所以用asp是看中它的rs.addnew这样的方式来添加数据,因为文章中可能含有未封闭的单引号或者双引号之类的,之前直接用insert,会出现错误,但在循环里又看不到,导致缺少文章的情况。所以你会看到有个tmpid,就是用来跟踪ID的,因为之前用php去添加数据,只会用insert来添加,导致缺少文章。
当然,如果你会PDO的话,请看下一篇:之PHP代码
Response.codepage = 65001
Response.charset = "utf-8"
'数据库连接
'A conn.open="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\a.mdb“
'B conn.open="DRIVER={SQLite3 ODBC Driver};DATABASE=D:\SQLITE\WWWW"
Server.ScriptTimeout = 500
Set conns = Server.CreateObject("ADODB.Connection")
Set rss = Server.CreateObject("ADODB.RecordSet")
conns.open "DRIVER={SQLite3 ODBC Driver};Database="&Server.MapPath("tt.db")
Set conna = Server.CreateObject("ADODB.Connection")
Set rsa = Server.CreateObject("ADODB.RecordSet")
conna.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db2-Ok.mdb")
ids = ""
id = ""
rsa.open "select * from Info order by ID asc",conna,3,1
rss.open "select * from Info",conns,1,3
If rss.eof Then
Do While Not rsa.eof
rss.addnew
rss("tid") = rsa("tid")
rss("xg") = rsa("xg")
rss("Title") = rsa("Title")
rss("Content") = rsa("Content")
rss("Author") = rsa("User")
rss("From") = rsa("From")
rss("hits") = rsa("hits")
If rsa("istj") = "True" Then
rss("istj") = 1
Else
rss("istj") = 0
End If
If rsa("isshow") = "True" Then
rss("isshow") = 1
Else
rss("isshow") = 0
End If
rss("isDel") = 0
rss("colorID") = 1
rss("addtime") = rsa("addtime")
'rss("tmpid") = rsa("ID")
rss.Update
rsa.movenext
Loop
End If
rsa.Close
rss.Close
Response.Write("Info导入成功")
Set rsa = Nothing
Set rss = Nothing
conna.close()
conns.close()
Set conna = Nothing
Set conns = Nothing
%>
上面的只是示例,本人曾经用过,还算不错,之所以用asp是看中它的rs.addnew这样的方式来添加数据,因为文章中可能含有未封闭的单引号或者双引号之类的,之前直接用insert,会出现错误,但在循环里又看不到,导致缺少文章的情况。所以你会看到有个tmpid,就是用来跟踪ID的,因为之前用php去添加数据,只会用insert来添加,导致缺少文章。
当然,如果你会PDO的话,请看下一篇:之PHP代码
- 没有相关文章
- 没有评论