Solved

TClientDataSet.ApplyUpdates

Posted on 2004-09-20
3
845 Views
Last Modified: 2008-03-06
Hi.

I update some data using the TClientDataSet.ApplyUpdates(0) method (TClientdataSet is connected to a TDataSetProvider which is connected to a TQuery).  This method returns the number of errors that occured while executing.

My question is simple :  how can I know what error actually did occured ?

Thanks :)
0
Comment
Question by:qas
  • 2
3 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
Comment Utility
do it like this:

  try
    ClientDataSet1.ApplyUpdates(0);
  except
    on E: Exception do
      begin
        MessageDlg(E.Message, mtError, [mbOK], 0);
        Exit;
      end;
  end;

  E.Message will give the exception error message, which is detailed error.
0
 

Author Comment

by:qas
Comment Utility
Hi.

Thanks for the comment.

The thing is that ClientDataSet1.ApplyUpdates(0) is a function returning an integer which is the number of errors that occured while updating the dataset.  Though I haven't tried it yet, I do believe that the actual call of this method CAN raise an exception (like if the dataset is locked or unavailable) but that is not what I'm really looking for.

For example, lets say the function returns 3.  I want to know what actully are those 3 errors that occured.

Thanks :)
0
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 50 total points
Comment Utility
in your case "ClientDataSet1.ApplyUpdates(0);" you send 0 for MaxErrors. This means if there is more than 0 errors, for e.g. 1 - you will go into the "except" block. There you have E.Message.

If you have more than 1 errors, you have to work with Reconcile method. Handle the errors in OnReconcileError.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

6 Experts available now in Live!

Get 1:1 Help Now