Recent

Author Topic: DbGrid or TSQLQuery best option  (Read 489 times)

eldonfsr

  • Hero Member
  • *****
  • Posts: 543
DbGrid or TSQLQuery best option
« on: March 05, 2025, 03:42:43 pm »
Hi i have a problem do you know when we have dbgrid user can go down or up how can know when he move to next record or select record to update a tabcontrol where is locate dbgrid...filter record on another table...

afterscroll or beforescroll , datasource  or  ondatachange

Thanks

TRon

  • Hero Member
  • *****
  • Posts: 4329
Re: DbGrid or TSQLQuery best option
« Reply #1 on: March 05, 2025, 04:02:46 pm »
Based on the description, though I have to guess a bit, you are probably referring to a master-detail solution.

See also our wiki where the concept is explained and an example provided. Here is another example (though it is quite old and I do not know if it still builds).
« Last Edit: March 05, 2025, 04:08:50 pm by TRon »
Today is tomorrow's yesterday.

egsuh

  • Hero Member
  • *****
  • Posts: 1594
Re: DbGrid or TSQLQuery best option
« Reply #2 on: March 06, 2025, 05:10:34 am »
In addition to TRon's comment, you should focus on 'TDataSet descendants', e.g. TSQLQuery, not TDBGrid. What DBGrid does is to show the state of TDataSet. Filtering, etc. should be done on TDataSet descendants.

wcage03

  • New Member
  • *
  • Posts: 27
Re: DbGrid or TSQLQuery best option
« Reply #3 on: March 18, 2025, 07:32:28 pm »
The DBGrid will show you visually which row you are on in the dataset. The SQLQuery will actually be tracking to the specific row. You can do something like SQLQuery1.FieldByName('SomeField').AsString (or AsInteger, etc.) to grab the value of a field on the row that the DBGrid shows as selected. The DBGrid does a lot of additional things, but one thing it does is act sort of like a navigator within the dataset.

 

TinyPortal © 2005-2018