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
PerW
Posts: 3
Joined: Sun 27 Apr 2008 21:50
Location: Norway

Master / Detail

Post by PerW » Mon 24 Jan 2011 13:43

Hi
I try make master detail with last version 5.00.03. On insert master id is not filled in before detail field is sent to sql server.
In DBMonitor I get this for Master insert:
SET ? = SCOPE_IDENTITY()
The Master field get new ID from server ,so it is the Detail key field that must be updated with Scope_Identity from master. Where do I set this.

I have set LocalMasterDetail = true for Detail.

Regards Per

AndreyZ

Post by AndreyZ » Wed 26 Jan 2011 11:48

Hello,

I cannot reproduce the problem. Please describe in details how you established the master/detail relationship.

Lithium™
Posts: 42
Joined: Wed 23 Jun 2010 06:42

Post by Lithium™ » Mon 14 Feb 2011 13:10

New problem under this subject.
Detail TMSQuery doesn't display anything when program runs under Windows7. This problem is unstable and only few machines doesn't work properly (units from hundreds). Under WindowsXP all machines work properly.

To solve this problem I replace Master/Detail ability with AfterScroll event handler on master-side which sent parameter to detail dataset. It's little uncomfortable to lose functionality and "downgrade" code of my program, isn't it?

What is the reason of this problem?

AndreyZ

Post by AndreyZ » Wed 16 Feb 2011 14:08

I cannot reproduce the problem. Please try composing a small sample to demonstrate the problem and send it to andreyz*devart*com, including a script to create and fill tables.

juanmaria
Posts: 14
Joined: Thu 11 Nov 2004 08:37

Post by juanmaria » Wed 02 Nov 2011 11:57

Hi,

I've just upgraded from SDAC 3 to 6 and I'm finding this very problem.

With SDAC 3 when I chaged the value of the master field on a table the detail table was updated inmediatly, now it seems that it is not updated at that moment.

When I scroll the master table it works fine, is when I change the value of a master field when it does not update.

I'm going to write some code on the onDataChange event of the DataSource to make a quick fix but a good solution would be desirable.

Right now I cannot make a sample and the program I'm working now is too huge but the thing is as follows:

TABLE A: MASTER
FIELDA1
FIELDA2
FIELDA3

TABLE B: DETAIL
FIELDB1
FIELDB2
FIELDB3

RELATION

FIELDB1 -> FIELDA1

In version 3 I did, for example:

TABLEA.edit;
TABLEAFIELDA1.Value := 'Something';
[and instantly TABLEB reflected the appropriate change]

Right now TABLEB has all its fields as null

AndreyZ

Post by AndreyZ » Wed 02 Nov 2011 13:21

Starting with SDAC 4.50.0.36, when master/detail relationship is used on inserting a new record into master table parameters in detail table are not updated. To restore the old behavior, set the RefreshParamsOnInsert global variable (that is declared in the MemDS unit) to True. For this, you should use the following code in one of the units of your application:

Code: Select all

initialization
  RefreshParamsOnInsert := True;

juanmaria
Posts: 14
Joined: Thu 11 Nov 2004 08:37

Post by juanmaria » Wed 02 Nov 2011 15:26

AndreyZ wrote:Starting with SDAC 4.50.0.36, when master/detail relationship is used on inserting a new record into master table parameters in detail table are not updated. To restore the old behavior, set the RefreshParamsOnInsert global variable (that is declared in the MemDS unit) to True. For this, you should use the following code in one of the units of your application:

Code: Select all

initialization
  RefreshParamsOnInsert := True;
Thank you, it worked like a charm!

AndreyZ

Post by AndreyZ » Wed 02 Nov 2011 15:35

Feel free to contact us if you have any other questions about SDAC.

Post Reply