I may be way off and this is a long shot, but I remember many years ago the Delphi TTable object (at least I think it was the TTable object) having a TransIsolation (transaction isolation) property that affected when you see changes to the underlying data. Changing the value of that property may help with your issue if you still want to use the TADOTable instead.
Regards From: [email protected] [mailto:[email protected]] On Behalf Of Eric A Sent: Wednesday, 16 May 2012 11:43 a.m. To: Delphi ListServer Subject: Re: [DUG] MSSQL DBGrid Refresh Thanks for the response, Rob. Interestingly, I have just changed from using the TADOTable objects for adding/deleting/editing the database table data and have instead now implemented those functions in TADOQuery objects. The problem appears to have been solved. I just follow the TADOQuery methods with either an ADOQuery.Requery([]) method invoation or the sequence of ADOQuery.Close then ADOQuery.Open (either has the the desired result). In this case its a pretty straightforward small application with only two distinct tables, i.e. there are no Master/Detail relationships to worry about. Normally, for more complex databases (eg with relationships between tables) I would use the SQL approach as you have intimated. Eric _____ Date: Wed, 16 May 2012 09:49:30 +1200 From: [email protected] To: [email protected] Subject: Re: [DUG] MSSQL DBGrid Refresh Hi I don't use the ADO components much but it sounds like a caching issue. I would definately NOT use table methods and do it all from SQL. Its much cleaner that way and you can see exactly what's going on, rather than letting a table component do the magic or running its own queries ! Cheers Rob On 16/05/2012 9:39 a.m., Eric A wrote: No, I've tried the Requery method and as I understand it the Requery method is effectively doing the same as the Open and Close sequence, i.e. forcing the select statement to be reissued against the database. For record deletion I call the nbDelete button method on the DBNavigator followed by closing/opening the ADOQuery and that does result in the data being refreshed in the DGBrid. For adding and editing records I am using the ADOTable "Append"/"Edit" and "Post" methods on the table followed by closing/opening the ADOQuery (or ADOQuery.Requery) and for some reason (which presently escapes me) the data is not refreshed in the grid. The question is should I even be using the ADOTable and would I better off just issuing raw SQL commands via the ADOCommand or similar component? Eric _____ Date: Tue, 15 May 2012 21:09:31 +1200 From: [email protected] To: [email protected] Subject: Re: [DUG] MSSQL DBGrid Refresh Hi Eric, With AdoQuery you can try Requery method. This article might help. http://edn.embarcadero.com/article/23011. Hope it helps Regards Vik On Tue, May 15, 2012 at 8:51 PM, Eric A <[email protected]> wrote: I am using a DBGrid with an ADOQuery component for display, with modifications to table data (edits, deletes, adds) being done using a ADOTable component. CRUD operations are done using the table methods rather than raw SQL code. There's a lot of fields in the database table so coding the operations in SQL would be a pain. Despite trying to refresh the data in the DBGrid by closing then re-opening both the ADOTable and the ADOQuery component the data in the DBGrid is not updated (unless I exit the application and restart. I've seen this problem mentioned in various postings but haven't yet seen a solution. Can someone supply the elusive technique to get the DBGrid data to refresh after the ADOTable data is changed? Eric. _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: [email protected] Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to [email protected] with Subject: unsubscribe -- vikas _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: [email protected] Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to [email protected] with Subject: unsubscribe _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: [email protected] Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to [email protected] with Subject: unsubscribe No virus found in this message. Checked by AVG - www.avg.com Version: 2012.0.2176 / Virus Database: 2425/5000 - Release Date: 05/15/12 _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: [email protected] Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to [email protected] with Subject: unsubscribe
_______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: [email protected] Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to [email protected] with Subject: unsubscribe
