Master Detail Cursor problem

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
saidus
Posts: 78
Joined: Wed 26 Oct 2005 09:54
Location: Algeria

Master Detail Cursor problem

Post by saidus » Mon 18 Feb 2008 07:06

Hi All ..
before all .. I USe MyDac 4.40.0.25 with MySQL 5.0.45 with DELPHI 7
so I think you know all the demo that come with delphi7 {{masapp}}
I have a problem in the same way :
I have 2 tables Master and Detail and i use the TMyQuery component.
In the detail table after posting [Detail OnAfterPost ] I've put some code to get Sum of one Field in this detail and post it in the master table
Description of Tables
Master Tables
CREATE TABLE `pers` (
`CodeM` char(5) NOT NULL,
`Nom` varchar(50) default NULL,
`Prenom` varchar(50) default NULL,
`Total` double default NULL,
PRIMARY KEY (`CodeM`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DEtail
CREATE TABLE `detail` (
`CodeD` int(11) NOT NULL auto_increment,
`CodeM` char(5) default NULL,
`Qte` float default NULL,
`PU` decimal(15,2) default NULL,
PRIMARY KEY (`CodeD`),
KEY `FK_detail` (`CodeM`),
CONSTRAINT `FK_detail` FOREIGN KEY (`CodeM`) REFERENCES `pers` (`CodeM`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
the Code that I use is

Code: Select all

procedure TForm1.DetailAfterPost(DataSet: TDataSet);
var
  b:TBookmark;
  p : Currency;
begin
  p:= 0;
  b:= Detail.GetBookmark ;
  Detail.DisableControls;
  Detail.First;
  while not Detail.Eof do
  begin
    p := p+DetailCalculated.Value;
    Detail.Next;
  end;    // while
  Detail.EnableControls;
  if bnil then
  begin
    Detail.GotoBookmark(b);
    Detail.FreeBookmark(b);
  end;
  if Master.StatedsEdit then
     Master.Edit;
  MasterTotal.Value:= p;
end;
it work without Problem but ... if I modify some value (do Edit Operation) in DBGrid the and when i press direction Keys in keybord (key up or down)Cursor jump anywhere else .. no to place that i want
why the cursor don't return to the prevus or next record
thanks

saidus
Posts: 78
Joined: Wed 26 Oct 2005 09:54
Location: Algeria

Post by saidus » Mon 18 Feb 2008 07:08

note that

Code: Select all

procedure TForm1.DetailAfterPost(DataSet: TDataSet);
var
  b:TBookmark;
  p : Currency;
begin
  p:= 0;
  b:= Detail.GetBookmark ;
  Detail.DisableControls;
  Detail.First;
  while not Detail.Eof do
  begin
    p := p+DetailCalculated.Value;
    Detail.Next;
  end;    // while
  Detail.EnableControls;
  if bnil then
  begin
    Detail.GotoBookmark(b);
    Detail.FreeBookmark(b);
  end;
  if Master.StatedsEdit then
     Master.Edit;
  MasterTotal.Value:= p;
end;
Field DetailCalculated is a calculated fied in detail table and he is calculated bu PU*Qte
thanks

saidus
Posts: 78
Joined: Wed 26 Oct 2005 09:54
Location: Algeria

Post by saidus » Mon 18 Feb 2008 14:10

I'm sure now that the problem is comming from mydac .. Ive try same operation with BDE and it works ...
I think the problem is from mydac 4.40.0.25

saidus
Posts: 78
Joined: Wed 26 Oct 2005 09:54
Location: Algeria

Post by saidus » Tue 19 Feb 2008 13:42

I've tried with ADO+ODBC and it works the cursor in DBGrid goes normally (not jumping)...
(I'm adressing to the corelab team)Please tell me if you plan to fix this bug or not else give me a solution to this ...
MyDac 4.40.0.25 + mysql 5.0.45
Thanks

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 20 Feb 2008 10:36

Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next MyDAC build.
As a temporary solution you can use the following code:

Code: Select all

procedure TForm1.DetailAfterPost(DataSet: TDataSet); 
var 
  b:TBookmark; 
  p : Currency; 
begin 
  p:= 0; 
  b:= Detail.GetBookmark ; 
  Detail.DisableControls; 
  Detail.First; 
  while not Detail.Eof do 
  begin 
    p := p+DetailCalculated.Value; 
    Detail.Next; 
  end;    // while 
  Detail.EnableControls; 
  if Master.StatedsEdit then 
     Master.Edit; 
  MasterTotal.Value:= p; 
  Master.Post; 

  if bnil then 
  begin 
    Detail.GotoBookmark(b); 
    Detail.FreeBookmark(b); 
  end; 
end; 

saidus
Posts: 78
Joined: Wed 26 Oct 2005 09:54
Location: Algeria

Post by saidus » Wed 27 Feb 2008 07:15

please tell me when you plan to make update for this version
mydac 4.40.0.25
thanks

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 28 Feb 2008 09:40

As for now we have no plan of updating this version.
In order to solve this problem, please send us your registration information by e-mail at dmitryg*crlab*com.

saidus
Posts: 78
Joined: Wed 26 Oct 2005 09:54
Location: Algeria

Post by saidus » Sat 01 Mar 2008 09:06

ok i'M SENDING IT >....

saidus
Posts: 78
Joined: Wed 26 Oct 2005 09:54
Location: Algeria

Post by saidus » Mon 03 Mar 2008 07:40

Ya Jdu ot vas Otvet ... Budete obnovit ety versiyu ili net ...
Pojalosta ya doljen Pisat Ochen Bolchoi Kod
Spocibo ....

saidus
Posts: 78
Joined: Wed 26 Oct 2005 09:54
Location: Algeria

Post by saidus » Mon 03 Mar 2008 07:41

Ya Jdu ot vas Otvet ... Budete obnovit ety versiyu ili net ...
Pojalosta ya doljen Pisat Ochen Bolchoi Kod
Ya vas Poslal Informatsii O registratsii 3 dnya nazad
Spocibo za pomoch....

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 04 Mar 2008 14:49

We have answered you by e-mail.

saidus
Posts: 78
Joined: Wed 26 Oct 2005 09:54
Location: Algeria

Post by saidus » Wed 05 Mar 2008 07:09

Thanks at all
It Works well

Post Reply