Page 1 of 1
HowTo update table records from controls connected to query?
Posted: Sat 07 Feb 2009 17:13
by Minotaurus007
I want to do a query, display the result, and change it.
I have:
Code: Select all
TMyTable T1, T2
TMyQuery Q // selecting some joins from T1, T2
Q->Edit(); // for editing
TMyDataSource QDS // connected to Q
TDBEdit QE // To display Q, E->ReadOnly = false, of course
Although I can edit data displayed by TDBEdit QE, they are not altered permanently, not within the Query and not int the Table. But that's what I want! A simple
does not work. When going back to the result-record, the old result is there again. Nothing has changed. I guess I have to alter some properties. What am I missing?
Posted: Mon 09 Feb 2009 09:40
by Dimon
Please make sure that the CachedUpdates property is set to False.
If it doesn't solve the problem, please try to compose a small sample to demonstrate the problem and send it to dmitryg*devart*com.
Posted: Sun 15 Feb 2009 12:27
by Minotaurus007
No, CachedUpdates is set to false and it's not working.
Meanwhile I tried to connect a DBNavigatorBar to the query. However, while editing still works, the changes after pressing "nbPost" are not permanent. Pressing "nbRefresh" on the NavigatorBar restores the changes in the control (TDBEdit or TDBGrid etc.) back to the original state.
I will try to compose a small program to demonstrate it.
Posted: Sun 15 Feb 2009 13:38
by Minotaurus007
Problem solved!
I missed the point that only the first table is updated in subsequent update-requests. When I changed
Code: Select all
SELECT * FROM T1, T2 WHERE...
to
SELECT * FROM T2, T1 WHERE...
everything worked, because in my application only T2 must be updated.
I already had failed to use the update property, because there was an exception as a result of identical fieldnames in two fields in both tables. Because of this one field had been automatically renamed to ID_1 (original ID) by the query. The update property failes to find ID_1 in the base table, of course, raising an exception. As a consequence I had not tried the update-property-approach anymore.
Posted: Tue 17 Feb 2009 12:44
by Dimon
It is good to see that this problem has been solved.