向包含无重复值索引的access数据库中批量添加数据

下面的例子演示了如何向access数据库中批量添加1000条内容重复的新闻项。初始数据库使用Ok3w 6.0动态版+静态版http://www.ok3w.net/)中提供的access数据库。附件中包含了程序完整的代码和数据库文件。

<%
Dim Conn
Dim Rs
Dim sql
' Create an ADO connection and recordset object
Set Conn = Server.CreateObject( " ADODB.Connection ")
Set Rs = Server.CreateObject( " ADODB.Recordset ")
Conn.Open  " DRIVER={Microsoft Access Driver (*.mdb)}; DBQ= " & Server.MapPath( " data.mdb ")
sql=  " SELECT ID, ChannelID,ClassID,SortPath,Title,Content FROM Ok3w_Article; " 

' Set the lock and cursor type
Rs.CursorType =  2 
Rs.LockType =  3 

Rs.Open sql, Conn     ' Open the recordset with sql query

For i =  1  To  1000

Rs.AddNew  ' Prepare the database to add a new record and add
Rs( " ID ") =  9 + i
Rs( " ChannelID ") =  1
Rs( " ClassID ") =  2
Rs( " SortPath ") =  " 0,1,2, "
Rs( " Title ") =  " test title "
Rs( " Content ") =  " test content "
Rs.Update    ' Save the update

Next
Rs.Close
Set Rs =  Nothing
Set Conn =  Nothing
%>
 
参考文章:

 

转载于:https://www.cnblogs.com/lijinyong/archive/2011/10/02/2197943.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值