Lazarus
Home
Forum
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
LCL
»
TDBGrid not working on TPageControl
Downloads
Daily Snapshots
FAQ
Wiki
Bugtracker
IRC channel
Developer Blog
Follow us on Twitter
Mailing List
Free pascal
Other languages
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
About donations (wiki)
Bookstore
Lazarus, the complete guide
Search
Advanced search
« previous
next »
Print
Pages: [
1
]
Author
Topic: TDBGrid not working on TPageControl (Read 643 times)
jack
Jr. Member
Posts: 82
TDBGrid not working on TPageControl
«
on:
February 03, 2012, 04:47:14 am »
I have a design that puts TDBGrid controls two layers deep on TPageControls. That is a TDBGrid on each page of a TPageControl which is itself on a page of another TPageControl. The Grid on the first tab works but the grids on other tabs will not update the database. In addition, when the grid on the first tab does work it disconnects the grids on the peer tabs. When I try to save the grids on the peer pages they fail and do not disconnect the grids on other tabs.
Logged
ludob
Hero Member
Posts: 623
Re: TDBGrid not working on TPageControl
«
Reply #1 on:
February 03, 2012, 08:48:01 am »
The location of a DBGrid, on a pagecontrol, nested x levels deep, doesn't influence its behavior.
What is the reason for using a separate transaction for every query? Separate transactions are only needed if you want to be able to commit/rollback completely independent updates. AFAIK, a connection only supports one active transaction at a time. This explains that the other grids are not working and inactive when working on the first grid. So, unless you have a very good reason, remove all these transactions and use one common transaction. If you don't want your users to work in multiple dbgrids at the same time, you can pull up a dialog box prompting the user to save or ignore his changes when changing to another TabSheet.
When I use multiple transactions I also use multiple connections: one transaction per connection.
What is the use of unit2? Are you in the middle of migrating to a data unit? For a bigger project with many queries and datasets, this is indeed a good idea. Sooner or later you'll add another form that also needs access to a common data source and referencing a data unit is much cleaner and less error-prone than accessing another form.
Logged
jack
Jr. Member
Posts: 82
Re: TDBGrid not working on TPageControl
«
Reply #2 on:
February 03, 2012, 04:56:38 pm »
Thank You for the insight. I was concerned about making changes on more than on sheet but I can easily limit the user to saving before leaving a tab.
Your right the unit2 was trash, I had attempted to use a datamodule to keep my data objects but found it confusing and couldn't make it work so I tried to get rid of it, the project inspector claimed to have deleted unit2 but it kept reappearing. I have deleted the files manually. This may have been my ignorance regarding the multiple transactions.
Thank you again.
Logged
jack
Jr. Member
Posts: 82
Re: TDBGrid not working on TPageControl
«
Reply #3 on:
February 03, 2012, 10:24:21 pm »
After cutting back to only one Transaction and reconnecting all the Queries through that one, I had exactly the same problem; when any grid would save and all the other grids would disconnect. My work around or perhaps the solution was to add a procedure to run after every save that would run through the transaction and all attached queries and set the Active Property back to true, starting with the transaction. This seems to have done the trick.
Thanks again!
Logged
tatamata
Sr. Member
Posts: 391
Re: TDBGrid not working on TPageControl
«
Reply #4 on:
February 04, 2012, 09:17:15 am »
Try to put panel on page control and then dbgrid on panel.
Logged
ludob
Hero Member
Posts: 623
Re: TDBGrid not working on TPageControl
«
Reply #5 on:
February 04, 2012, 10:11:48 am »
Commit closes all datasets using that transaction. Use CommitRetaining if you want to keep the datasets opened.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
LCL
»
TDBGrid not working on TPageControl
Recent
StringGrid.LoadFromCSVFil...
by
tedsmith
[
Today
at 11:17:52 pm]
TaChart ternary plot func...
by
ccrause
[
Today
at 10:53:15 pm]
Things went wrong install...
by
garlar27
[
Today
at 10:46:45 pm]
Installing Lazarus/FPC on...
by
Bruce Mayo
[
Today
at 10:21:17 pm]
"Tween" two images
by
TheBlackSheep
[
Today
at 09:38:04 pm]
another bug?
by
circular
[
Today
at 08:36:16 pm]
BGRABitmap 5.7.1 won't co...
by
circular
[
Today
at 08:24:59 pm]
Q about capabilities of t...
by
ludob
[
Today
at 07:39:16 pm]
Cross Compile
by
Leledumbo
[
Today
at 05:23:05 pm]
Stable database?
by
BigChimp
[
Today
at 03:27:28 pm]