Page 1 of 1

Master Detail Cursor problem

Posted: Mon 18 Feb 2008 07:06
by saidus
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

Posted: Mon 18 Feb 2008 07:08
by saidus
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

Posted: Mon 18 Feb 2008 14:10
by saidus
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

Posted: Tue 19 Feb 2008 13:42
by saidus
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

Posted: Wed 20 Feb 2008 10:36
by Dimon
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; 

Posted: Wed 27 Feb 2008 07:15
by saidus
please tell me when you plan to make update for this version
mydac 4.40.0.25
thanks

Posted: Thu 28 Feb 2008 09:40
by Dimon
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.

Posted: Sat 01 Mar 2008 09:06
by saidus
ok i'M SENDING IT >....

Posted: Mon 03 Mar 2008 07:40
by saidus
Ya Jdu ot vas Otvet ... Budete obnovit ety versiyu ili net ...
Pojalosta ya doljen Pisat Ochen Bolchoi Kod
Spocibo ....

Posted: Mon 03 Mar 2008 07:41
by saidus
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....

Posted: Tue 04 Mar 2008 14:49
by Dimon
We have answered you by e-mail.

Posted: Wed 05 Mar 2008 07:09
by saidus
Thanks at all
It Works well