This Domain(Admin5.com) is for Sale:

关于将数据成批导入新数据库的程序例子(Access to Sql)

时间:2007-12-23  来源:不详  作者:迈克DB
前两天一位朋友在论坛中问到怎样把成批倒入另外的,当时只是简单的回答了一下用循环就可以了,正好在我论坛改版碰到原来精华贴子需要倒入到新的中,于是就写了下面一段程序来实现,很简单,大家参考一下吧~!
织梦好,好织梦

<!------把所有精华贴子加入新good v0.1---------->
<!--#include file="conn."-->
<%
dim announceid
dim username
dim useremail
dim boardid
dim topic
dim body
dim dateandtime
dim hits
dim length
dim Expression
REM 打开ACCESS
set uconn=server.createobject("adodb.connection")
DBPath = Server.MapPath("club.mdb")
uconn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
REM 打开SQL
set conn=server.createObject("ADODB.Connection")
connstr="DSN=sky;UID=sa;PWD="
conn.open connstr copyright dedecms

set urs=uconn.execute("SELECT * FROM bbs1 WHERE isbest=1 ORDER BY announceID")
do while not urs.eof
announceid=urs("announceid")
username=trim(urs("username"))
useremail=trim(urs("useremail"))
boardid=urs("boardid")
topic=trim(urs("topic"))
body=trim(urs("body"))
dateandtime=urs("dateandtime")
hits=urs("hits")
length=urs("length")
Expression=urs("Expression")
dim cmdTemp
dim InsertCursor
dim dataconn
Set DataConn = Server.CreateObject("ADODB.Connection")
dataconn.open connstr
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set InsertCursor = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText="SELECT * FROM good WHERE (UserName IS NULL)"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = dataconn
InsertCursor.Open cmdTemp, , 1, 3
InsertCursor.AddNew

本文来自织梦

InsertCursor("BoardID")=boardID
InsertCursor("UserName")=UserName
InsertCursor("UserEmail")=UserEmail
InsertCursor("Topic")=Topic
InsertCursor("Body")=Body
InsertCursor("DateAndTime")=DateandTime
InsertCursor("hits")=hits
InsertCursor("length")=length
InsertCursor("Expression")=Expression
InsertCursor.Update
response.write "转化纪录"&announceid&"成功<br>"
urs.movenext
loop
urs.close
rs.close
set conn=nothing
set uconn=nothing
%>
作者:沙滩小子,转载请注明出处动网先锋
  

看完这篇,您有何感觉呢?

文章评论

共有位Admini5网友发表了评论 查看完整内容

24小时热门信息