Page 1 of 1
Refreh Master in Master/Detail
Posted: Sat 04 Nov 2006 17:14
by Lexander
Hi.
I use 2 MSQuery in master/detail relantionship (named Q1 and QFloat).
I use stored procedure to update user input data from QFloat.
Stored procedure updates 2 tables (used in both MSQuery) on the server.
How can I refresh master datasourse (all or one record only) after updating some detail data?
Thank you.
Posted: Mon 06 Nov 2006 09:07
by Jackson
You can use TCustomDADataSet.AfterUpdateExecute event to call TDataSet.Refresh or TCustomDADataSet.RefreshRecord method for master DataSet.
Posted: Mon 06 Nov 2006 12:04
by Lexander
Thanks.
The code below works fine.
Code: Select all
procedure TTirePrice.QFloatAfterUpdateExecute(Sender: TCustomMSDataSet;
StatementTypes: TStatementTypes; Params: TMSParams);
begin
if stUpdate in StatementTypes then
begin
if Integer(Params.ParamByName('RETURN_VALUE').Value)0 then
begin
MyMessage('Error '+'.'+chr(13)+'Code: '+String(Params.ParamByName('RETURN_VALUE').Value));
end;
Q1.Refresh;
QFloat.Refresh;
end;
end;
Maybe, my little experience will be useful for other programmers.
If I don't call Refresh method for QFloat, next update for QFloat raise the exception:
Exception class EAssertionFailed with message 'DisposeBuf failed (MemData.pas, line 6469)'.
Posted: Tue 07 Nov 2006 12:30
by Lexander
Hi again.
Note please.
I try to edit QFloat data and catch the exception.
Process is:
1. I scroll to row number 100 (for example) of Q1.
2. I try to edit different rows of QFloat.
If I try to update twice the same row of QFloat, same exception (see my post upper) fires.
If I update other row of QFloat and then return to edit first row - it's OK.
Why it's happens and how to correct it?
PS
Code of procedure and exception text I posted earlier.
Posted: Wed 08 Nov 2006 08:30
by Jackson
We couldn't reproduce the problem.
Please send us (sdac*crlab*com) a complete small test project to reproduce the problem; it is desirable to use Northwind or Master schema objects, otherwise include definition of your own database objects; don't use third party components.
Also supply us following information
- Exact version of Delphi
- Exact version of SDAC. You can see it in About sheet of TMSConnection Editor
- Exact version of Microsoft SQL Server and OLE DB provider that you use. You can see it in Info sheet of TMSConnection Editor
Posted: Thu 09 Nov 2006 10:23
by Jackson
You are right. You can't call TDataSet.Refresh method of master DataSet in TCustomDADataSet.AfterUpdateExecute event handler of detailed DataSet.
But you can use TDataSet.AfterPost event for this purpose instead of TCustomDADataSet.AfterUpdateExecute.
Posted: Thu 09 Nov 2006 10:45
by Lexander
Thank you for a help. A problem is decided.