Recent

Author Topic: [SOLVED} Proper method to use  (Read 2037 times)

dodgebros

  • Full Member
  • ***
  • Posts: 165
[SOLVED} Proper method to use
« on: October 23, 2023, 06:35:58 pm »
Is this the proper way to code using these components, in particular do I need to set DataModule1.SQLTransPlsizes.Active equal false after a commit?  SQLTransPlsizes is a TSQLTransaction component from the SQLdb tab.
TD
 
Code: [Select]
  DataModule1.SQLQryPlsizes.SQL.Text := "SELECT * FROM tblPlsizes";
  DataModule1.SQLTransPlsizes.Active := true;
  DataModule1.SQLQryPlsizes.ExecSQL;
  DataModule1.SQLTransPlsizes.Commit;
  DataModule1.SQLTransPlsizes.Active := false;
« Last Edit: October 24, 2023, 05:12:27 pm by dodgebros »

cdbc

  • Hero Member
  • *****
  • Posts: 1771
    • http://www.cdbc.dk
Re: Proper method to use
« Reply #1 on: October 24, 2023, 08:18:25 am »
Hi
TMK, "DataModule1.SQLTransPlsizes.Commit;" aswell as "DataModule1.SQLTransPlsizes.Rollback;" ends the transaction started with "DataModule1.SQLTransPlsizes.Active := true;"
So there's NO need for this: "DataModule1.SQLTransPlsizes.Active := false;"
HTH
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

Leledumbo

  • Hero Member
  • *****
  • Posts: 8783
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Proper method to use
« Reply #2 on: October 24, 2023, 08:23:02 am »
in particular do I need to set DataModule1.SQLTransPlsizes.Active equal false after a commit?
No, Commit will deactivate it as well. CommitRetaining is available if you want to keep the transaction open. I suggest reading SqlDBHowto to clear the confusion about how the various DB components work together, such as when StartTransaction is required to be explicitly called and when it's not.

dodgebros

  • Full Member
  • ***
  • Posts: 165
Re: Proper method to use
« Reply #3 on: October 24, 2023, 05:11:42 pm »
Thanks for thee reply's, I will indeed read the SqlDBHowTo.
TD

 

TinyPortal © 2005-2018