What am I doing wrong?
-
DaveRowland
- Posts: 4
- Joined: Mon 19 Feb 2007 23:17
What am I doing wrong?
I have a window using a TMyQuery object to point to a table on the database and have set up the insert, delete and update SQL commands.
I have set cachedupdates ON.
I retrieve the information fine and it displays fine.
If I edit a column and call the ApplyUpdates method, the database gets updated.
My problem is, if I do change columns in edit fields on the window, the UpdatesPending always returns FALSE and the UpdateStatus always returns usUnmodified.
According to the online help, these should return possitive when the data has been altered for a cachedupdate.
How am I suppose to tell when changes have been made to the dataset prior to doing an update?
I need to know as I do not want to always tell the user to save their changes if there is nothing to save.
I have set cachedupdates ON.
I retrieve the information fine and it displays fine.
If I edit a column and call the ApplyUpdates method, the database gets updated.
My problem is, if I do change columns in edit fields on the window, the UpdatesPending always returns FALSE and the UpdateStatus always returns usUnmodified.
According to the online help, these should return possitive when the data has been altered for a cachedupdate.
How am I suppose to tell when changes have been made to the dataset prior to doing an update?
I need to know as I do not want to always tell the user to save their changes if there is nothing to save.
-
DaveRowland
- Posts: 4
- Joined: Mon 19 Feb 2007 23:17
I am using the latest objects. They have just been downloaded.Antaeus wrote:What MyDAC version are you using?
4.40.0.22
No, this seams to work.Antaeus wrote:Are you able to reproduce this problem in the CachedUpdates demo of MyDAC?
The difference is that the demo uses a grid control where as I use dbedit controls on my form.
The window I am displaying the information on only contains one row as it is for opening and editing one client.
I would asume that, as I can change the columns on the client table by changing the data in the dbedit columns and performing an applyupdates, if I was to change the data for a column I can check for this change using either the UpdatesPending or UpdateStatus methods.
However, it does not matter how many items I change on the window, UpdatesPending always returns false and UpdateStatus always returns usUnmodified.
It seams that maybe these two methods are looking at a differnent row on the dataset then the current row being edited.
Am I using these methods correctly? The online help for these methods seams very vague.
Is there suppose to be a property or method I can poll to tell me if there are any inserts, deletes or updates pending against the entire dataset?
I modified the CachedUpdates demo so that data is displayed in the DBEdit controls instead of DBGrid. While testing this project I did not notice any problems. The UpdatesPending and UpdateStatus properties were working correctly.
Please modify the CachedUpdates demo so that the problem is reproduced and send me this demo at evgeniyd*crlab*com.
Please modify the CachedUpdates demo so that the problem is reproduced and send me this demo at evgeniyd*crlab*com.
-
DaveRowland
- Posts: 4
- Joined: Mon 19 Feb 2007 23:17
Thank you for your sample. If you edited a record but did not post it, the record status is not changed (UpdatesPending state is not changed too). It will change after you apply changes to dataset. So, try to check the dataset state before checking the UpdatesPending property. This may look like the following:
Code: Select all
if MyQuery.State = dsEdit then
MyQuery.Post;
if MyQuery.UpdatesPending then
Label10.Caption:= 'True'
else
Label10.Caption:='False';-
DaveRowland
- Posts: 4
- Joined: Mon 19 Feb 2007 23:17
Thanks for your reply.
There is no mention of this in the online help which is where we tend to get stuck.
I just wish Borland will make their help system a lot more intutative then what it currently is.
I have got it working now. Thanks and hopefully this will also help other newbies who have the same problem in their code.
There is no mention of this in the online help which is where we tend to get stuck.
I just wish Borland will make their help system a lot more intutative then what it currently is.
I have got it working now. Thanks and hopefully this will also help other newbies who have the same problem in their code.