Update failed "found 0 records"

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ralle1
Posts: 42
Joined: Thu 27 May 2010 15:01

Update failed "found 0 records"

Post by ralle1 » Thu 11 Nov 2010 11:43

Hello!

I ve got a problem with an Edit/Post in the following case:

Code: Select all

      Options.StrictUpdate := true;

      SQL.ADD('SELECT *');
      SQL.ADD('FROM TABLE WHERE Key1=:Key1');
      SQL.ADD('AND Month=:Month');
      SQL.ADD('AND Year=:Year');

      ParamByName('Key1').AsInteger := Key1;
      ParamByName('Month').AsInteger := Month;
      ParamByName('Year').AsInteger := Year;

      Open;
      First;
      while not EOF do
      begin
        Edit;
        FieldByName('Monat').AsInteger := NextMonth;
        FieldByName('Jahr').AsInteger := NextYear;
 
        //RowsAffected = -1
       
        Post;

        //RowsAffected = 0 

        Next;
      end;
      Close;
On Post it triggers the message: Update failed "found 0 records"
but the Record is changed, so the Update didn't failed, only RowsAffected seems to show the wrong value, its RowsAffected=0

Version: Devart SDAC 4.70.0.47 for Delphi 2007 for Win32.

Please help me. Thanks!

AndreyZ

Post by AndreyZ » Thu 11 Nov 2010 13:10

Hello,

If you are using triggers for this table, you should set the TMSQuery.Options.StrictUpdate option to False. If you don't use triggers, check that the SQL Server NOCOUNT option is OFF. Also check that your table has Primary Key.
For more information please read the description of the StrictUpdate option in SDAC Reference Manual.

ralle1
Posts: 42
Joined: Thu 27 May 2010 15:01

Post by ralle1 » Thu 11 Nov 2010 13:38

Thank you for your tip.

You are right. The table has a Before-Update-Trigger. There is an Update, wich affects 0 records.

AndreyZ

Post by AndreyZ » Thu 11 Nov 2010 13:50

It is good to see that this problem was solved. Feel free to contact us if you have any further questions about SDAC.

Post Reply