Refreh Master in Master/Detail

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Lexander
Posts: 4
Joined: Sat 04 Nov 2006 16:22

Refreh Master in Master/Detail

Post by Lexander » Sat 04 Nov 2006 17:14

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.

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Mon 06 Nov 2006 09:07

You can use TCustomDADataSet.AfterUpdateExecute event to call TDataSet.Refresh or TCustomDADataSet.RefreshRecord method for master DataSet.

Lexander
Posts: 4
Joined: Sat 04 Nov 2006 16:22

Post by Lexander » Mon 06 Nov 2006 12:04

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)'.

Lexander
Posts: 4
Joined: Sat 04 Nov 2006 16:22

Post by Lexander » Tue 07 Nov 2006 12:30

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.

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Wed 08 Nov 2006 08:30

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

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Thu 09 Nov 2006 10:23

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.

Lexander
Posts: 4
Joined: Sat 04 Nov 2006 16:22

Post by Lexander » Thu 09 Nov 2006 10:45

Thank you for a help. A problem is decided.

Post Reply