Multiple Updates

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for MySQL in Delphi and C++Builder
Post Reply
Posts: 1
Joined: Mon 14 Feb 2011 11:22

Multiple Updates

Post by Fretman » Mon 14 Feb 2011 11:33

This is a very simple question am sure someone can point me in the correct direction.

I apologise for my lack of experience using Databases.

I need to Update a Table which contains many items ( 2000 ) i need to update one field named status for as many as 300 items every 10 seconds. Since this is the duration of updates I receive fro a piece of hardware and the table needs to be kept current.

I have tried doing each update one after the other but this takes a very long time and does not complete before another batch of updates is received.

The question is : What is the best way to do this? Can i send all 300 updates at the same time? and how using Delphi? I am developing the application using Delphi 2006.



Post by AndreyZ » Wed 16 Feb 2011 14:09


You should use the TClientDataSet component to update a table. TClientDataSet is a component that stores all changes in memory until the ApplyUpdates method is called. Here is a code example:

Code: Select all

  while not ClientDataSet.Eof do begin
    // your changes
    ClientDataSet3.Post; // here changes are stored only in memory
  ClientDataSet3.ApplyUpdates(0); // here all changes are sent to the server in one batch. dbExpress uses transactions for this.

Post Reply