ASP源码.NET源码PHP源码JSP源码JAVA源码DELPHI源码PB源码VC源码VB源码Android源码

使用ADO批量更新记录(ASP)

来源:网络整理     时间:2014-10-19     关键词:

本篇文章主要介绍了"使用ADO批量更新记录(ASP)",对于ASPjrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播感兴趣的同学可以参考一下:

'**************************************
    ' 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 %>
    
    <% Next %>
    
    <% For j = 1 To 5 %>
    
    <% For i = 0 To rs.Fields.Count - 1 %>
    
    <% Next %>
    
    <%
    rs.MoveNext
    Next
    rs.MoveFirst
    %>
    
<%= rs(i).Name %>
<%= rs(i) %>

    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 %>
    
    <% Next %>
    
    <% For j = 1 To 5 %>
    
    <% For i = 0 To rs.Fields.Count - 1 %>
    
    <% Next %>
    
    <%
    rs.MoveNext
    Next
    rs.Close
    Cn.Close
    %>
    
<%= rs(i).Name %>
<%= rs(i) %>


以上就介绍了使用ADO批量更新记录(ASP),包括了方面的内容,希望对ASPjrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播有兴趣的朋友有所帮助。

本文网址链接:http://www.codes51.com/article/detail_332.html

相关图片

相关文章