Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 1
Joined: Fri 12 Oct 2012 20:45


Post by klocer » Mon 15 Oct 2012 11:50

We are moving from a different database (Advantage Database Server - ADS) to SQL Server and have come across some functionality that is not consistent with what we have encountered before. I am not sure if there is some option we need to flag or ultimately it just does not exist. The scenario is we execute a SQL call with a where clause that limits the number of records returned to a grid. Users are able to edit records via the grid. One of the fields that can be edited is one that is used in the where clause. In the ADS database when the record is posted the record is removed from the grid due to it not meeting the criteria of the where clause without having to do anything. With the TMSQuery component this does not happen. Is there some setting that duplicates this type of behavior?


Re: Functionality

Post by AndreyZ » Mon 15 Oct 2012 14:18


To solve the problem, you should refresh a dataset after posting changes (you can use for this the AfterPost event). Here is a code example that demonstrates this:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
  MSQuery1.SQL.Text := 'select * from dept where dname=:dname';
  MSQuery1.ParamByName('dname').AsString := 'RESEARCH';
  MSQuery1.FieldByName('dname').AsString := 'RESEARCH1'; // the new value that does not match the WHERE condition

procedure TForm1.MSQuery1AfterPost(DataSet: TDataSet);
  MSQuery1.Refresh; // refreshing data

Post Reply