-
您的位置:首页 → 技术开发 → ASP技巧 → 使用ADO批量更新记录(源代码)
使用ADO批量更新记录(源代码)
时间:2004/11/7 4:02:00来源:本站整理作者:蓝点我要评论(0)
-
'**************************************
' Name: Batch Update using ADO
' Description:ADO has a great batch upda
' te feature that not many people take adv
' antage of. You can use it to update many
' records at once without making multiple
' round trips to the database. Here is how
' to use it.
' By: Found on the World Wide Web
'
'
' Inputs:None
'
' Returns:None
'
'Assumes:None
'
'Side Effects:None
'
'Warranty:
'code provided by Planet Source Code(tm)
' (http://www.Planet-Source-Code.com) 'as
' is', without warranties as to performanc
' e, fitness, merchantability,and any othe
' r warranty (whether expressed or implied
' ).
'**************************************
Place Document Title Here
<%
Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.RecordSet")
cn.Open Application("guestDSN")
rs.ActiveConnection = cn
rs.CursorType = adOpenStatic
rs.LockType = adLockBatchOptimistic
rs.Source = "SELECT * FROM authors"
rs.Open
If (rs("au_fname") = "Paul") or (rs("au_fname") = "Johnson") Then
newval = "Melissa"
Else
newval = "Paul"
End If
If err <> 0 Then
%>
Error opening RecordSet
<% Else %>
Opened Successfully
<% End If %>
Before Batch Update
<% For i = 0 To rs.Fields.Count - 1 %>
<%= rs(i).Name %> |
<% Next %>
<% For j = 1 To 5 %>
<% For i = 0 To rs.Fields.Count - 1 %>
<%= rs(i) %> |
<% Next %>
<%
rs.MoveNext
Next
rs.MoveFirst
%>
Move randomly In the table and perform updates To table.
<%
Randomize
r1 = Int(rnd*3) + 1 ' n Itterations
r2 = Int(rnd*2) + 1 ' n places skipped between updates
For i = 1 To r1
response.write "Itteration: " & i & "
"
rs("au_fname") = newval
For j = 1 To r2
rs.MoveNext
response.write "Move Next
"
Next
Next
rs.UpdateBatch adAffectAll
rs.Requery
rs.MoveFirst
%>
<% rs.MoveFirst %>
After Changes
<% For i = 0 To rs.Fields.Count - 1 %>
<%= rs(i).Name %> |
<% Next %>
<% For j = 1 To 5 %>
<% For i = 0 To rs.Fields.Count - 1 %>
<%= rs(i) %> |
<% Next %>
<%
rs.MoveNext
Next
rs.Close
Cn.Close
%>
相关阅读
Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么
-
热门文章
没有查询到任何记录。
最新文章
VB.NET 2005编写定时关
Jquery get/post下乱码解决方法 前台gbk gb如何使用数据绑定控件显示数据ASP脚本循环语句ASP怎么提速
人气排行
轻松解决"Server Application Error"和iis"一起学习DataGridView调整列宽用ASP随机生成文件名的函数Jquery get/post下乱码解决方法 前台gbk gbODBC Drivers错误80004005的解决办法返回UPDATE SQL语句所影响的行数的方法用Javascript隐藏超级链接的真实地址两个不同数据库表的分页显示解决方案
查看所有0条评论>>