Page 1 of 1
Master/Detail Relatioship Broke
Posted: Mon 11 Oct 2010 16:59
by jigesh
Hi
After upgrading from SDAC 3.70.2.28 to SDAC 5.00.0.1 my Master/Detail relationship is broken. I cannot see any detail records. If I run my app which was complied with the old version everything works fine. Are there any new settings I should be aware when using the latest version od SDAC? All my relations are setup correctly. I have the master dataset as the MasterSourceDataset for the detail dataset. Please help. I have many master/detail relationsships in my app.
Thanks
From
Jigesh
Posted: Tue 12 Oct 2010 07:49
by AndreyZ
Hello,
I couldn't reproduce the problem. I have created a master/detail relationship using SDAC 3.70.2.28 and it correctly works with SDAC 5.00.0.1. Please, try creating a new master/detail relationship using SDAC 5.00.0.1. If it doesn't work then check that you don't have any old dcu files from SDAC 3.70.2.28 in your project. If the problem persists, please post here the piece of code where you are initializing the master/detail relationship.
Posted: Wed 13 Oct 2010 17:53
by tyassin
Jigesh is right. I just discovered that today. To reproduce it is simple:
1- Create a table: Cats (ID, Name) and fill it with some data.
2- Create another table: Products (ID, Name, CatID)
3- Add the two tables to a form and create the necessary master-detail relation ship
4- Add DBEdit components for the Products fields
5- Add DBLabel and link it to Cats.Name
6- Now, when you add a new product and write a CatID that exists in the Cats table, the DBLabel show the name correctly. This behavior is broken in 5.00.0.1.
7- If you save the record and open it again, it will show the category name correctly.
8- Now, the only way to get the correct behavior back is to add an OnExit even to the DBEdit of the Products.CatID where you have to Cats.Close and Cats.Open. Refresh doesn't work.
Posted: Thu 14 Oct 2010 08:44
by AndreyZ
I'm using the following code to establish master/detail relationship between two tables:
Code: Select all
tblMaster.TableName := 'Emp';
tblDetail.TableName := 'Dept';
tblDetail.MasterSource := dsMaster;
tblDetail.MasterFields := 'ID';
tblDetail.DetailFields := 'EmpID';
DBText_EmpName.DataSource := dsMaster;
DBText_EmpName.DataField := 'Name';
DBEdit_DeptID.DataSource := dsDetail;
DBEdit_DeptID.DataField := 'ID';
DBEdit_DeptName.DataSource := dsDetail;
DBEdit_DeptName.DataField := 'Name';
DBEdit_DeptEmpID.DataSource := dsDetail;
DBEdit_DeptEmpID.DataField := 'EmpID';
tblMaster.Open;
tblDetail.Open;
I'm using the following code to add a new record to the detail table (button click):
Code: Select all
tblDetail.Append;
tblDetail.FieldByName('ID').AsInteger := StrToInt(edNewDeptID.Text);
tblDetail.FieldByName('Name').AsString := edNewDeptName.Text;
tblDetail.FieldByName('EmpID').AsInteger := StrToInt(edNewDeptEmpID.Text);
tblDetail.Post;
Are you using the same code? If no, please, correct it so I can reproduce the problem. If yes, specify which component behaves incorrectly?
Also you can compose a small sample to demonstrate the problem and send it to andreyz*devart*com.
Posted: Thu 14 Oct 2010 13:24
by tyassin
Project and Tables sent by mail as requested.
All you have to do is Insert a new record and input 1 or 2 as the product type.
Posted: Fri 15 Oct 2010 10:44
by AndreyZ
To solve the problem set the RefreshParamsOnInsert global variable from the DBAccess unit to True. Notice that if you have a lot of master/detail relationships, setting this variable to True may cause performance decreasing.
Posted: Fri 15 Oct 2010 18:31
by jigesh
AndreyZ wrote:To solve the problem set the RefreshParamsOnInsert global variable from the DBAccess unit to True. Notice that if you have a lot of master/detail relationships, setting this variable to True may cause performance decreasing.
Where do I find RefreshParamsOnInsert option. Which dataset is involved.
Thanks
Jigesh
Posted: Mon 18 Oct 2010 09:20
by AndreyZ
RefreshParamsOnInsert is a global variable from the DBAccess unit. To use it, add DBAccess unit in the uses clauses of your unit and write the following code:
All datasets use this variable for master/detail relationships.
Posted: Wed 20 Oct 2010 14:29
by jigesh
AndreyZ wrote:RefreshParamsOnInsert is a global variable from the DBAccess unit. To use it, add DBAccess unit in the uses clauses of your unit and write the following code:
All datasets use this variable for master/detail relationships.
Hi AndreyZ,
Your suggestion worked very well for me.
Thanks
Posted: Wed 20 Oct 2010 14:39
by AndreyZ
I am happy that this problem has been solved. If any other questions come up, please contact me.