Page 1 of 1

Update failed "found 0 records"

Posted: Thu 11 Nov 2010 11:43
by ralle1
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!

Posted: Thu 11 Nov 2010 13:10
by AndreyZ
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.

Posted: Thu 11 Nov 2010 13:38
by ralle1
Thank you for your tip.

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

Posted: Thu 11 Nov 2010 13:50
by AndreyZ
It is good to see that this problem was solved. Feel free to contact us if you have any further questions about SDAC.