Recent

Author Topic: How to disconnect db controls  (Read 4169 times)

Bert_Plitt

  • Jr. Member
  • **
  • Posts: 59
How to disconnect db controls
« on: November 29, 2021, 08:21:47 pm »
I'm running sqlite3 with Lazarus in Windows 10.  I have a form with several db controls connected to various fields of dbTable1, plus the form contains a TSQLite3, TSQLTransaction, TDataSource, and a TSQLQuery.  My app sequentially steps through the table from first record to last record.  At each record, I query the table, read the data, and then step to the next record.  At the end of the sequence, I'll need to re-connect the controls. 

I remember seeing a code example to do the above using a try/finally construct, but cannot find it anymore.  Can anyone provide some code that disconnects the controls from the table so that they do not display the changing values until the end of the query. 
Windows 10, Lazarus 2.2.0 RC1, FPC 3.2.2

Sieben

  • Sr. Member
  • ****
  • Posts: 299
Re: How to disconnect db controls
« Reply #1 on: November 29, 2021, 08:27:40 pm »
I think you are looking for TDataSet or in your case TSQLQuery methods DisableControls / EnableControls. But you might as well want to consider a second dataset for your iterations.
« Last Edit: November 29, 2021, 08:44:01 pm by Sieben »
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

Bert_Plitt

  • Jr. Member
  • **
  • Posts: 59
<SOLVED> Re: How to disconnect db controls
« Reply #2 on: November 30, 2021, 03:21:31 am »
Got it!  Thanks Sieben.
Windows 10, Lazarus 2.2.0 RC1, FPC 3.2.2

 

TinyPortal © 2005-2018