ADO Batch update - very slow

Posted on 2005-04-29
Last Modified: 2013-12-25

I have a process that is written in VB that enters a calculated record into a feild in table is SQL Server.  There are currently 222,872 records  in the table.

The code that performs this operation is:

    Set rsql = New Recordset
    rsql.Open sSQL, CN, adOpenDynamic, adLockBatchOptimistic
        Do Until rsql.EOF
                   rsql!task2 = (ReturnModTask2(rsql!TaskNum))
                   x = x + 1
                   lblRecordeCount.Caption = x

The code makes it through the loop quite quickly but then seems to stall on the rsql.UpdateBatch.

Can you offer any suggestions to do this more efficiently?


Question by:dselby5
    LVL 11

    Accepted Solution

    well.. the batch update is doing the actual work in the database
    so it'll be the slow..

    what is ReturnModTask2 doing?
    LVL 29

    Assisted Solution

    You are likely to get a better performance by using a SQL UPDATE statement and executing it on the Connection object, but it does depend on that ReturnModTask2  is doing.


    Author Comment

    It turn out that in this case there was no primary key.  After the primay key was applied the process speed was increase 4000 fold.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    Title # Comments Views Activity
    How do I open a VB6 code? 16 34
    create a utf8 text file using vba 2 72
    Replace Formatted Numbers with text 9 43
    Adding to a VBA? 6 30
    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now