Recent

Author Topic: Commit changes wiith DBEdit  (Read 13689 times)

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1315
Re: Commit changes wiith DBEdit
« Reply #15 on: March 10, 2016, 11:17:33 am »
The easiest way to discard all changes at the end is by using TSQLTransaction.Rollback.

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: Commit changes wiith DBEdit
« Reply #16 on: March 10, 2016, 04:01:53 pm »
The easiest way to discard all changes at the end is by using TSQLTransaction.Rollback.
That would be fine if the TDbf (which Edson, TS, uses) has a transaction-facility, but it doesn't.

Edson

  • Hero Member
  • *****
  • Posts: 1325
Re: Commit changes wiith DBEdit
« Reply #17 on: March 10, 2016, 05:09:13 pm »
I'm agreed with rvk. DBGrid is not the place to do this. I created a small demo for using DBEdits and Edits in a configdialog with the buttons you want. I hope it helps.

Thanks @mangakissa, I'm going to study your code.  :)  I think it will be very instructive.

But I'm afraid, I need to modify a complete table (no only a row) and then, have the ability to discard or save all the changes.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: Commit changes wiith DBEdit
« Reply #18 on: March 10, 2016, 09:36:39 pm »
But I'm afraid, I need to modify a complete table (no only a row) and then, have the ability to discard or save all the changes.
I think the only option you have left, in that case, is using a TStringGrid (with goEditing in the Options). You can populate the StringGrid when entering the form en when the user wants to save the options you can write the rows to the database again.

Edson

  • Hero Member
  • *****
  • Posts: 1325
Re: Commit changes wiith DBEdit
« Reply #19 on: March 11, 2016, 01:59:04 am »
Yes. That's the way. Actually I'm following the same scheme I've used in my ConfigFrame library:

Code: Pascal  [Select][+][-]
  1.  +-----------+                  +-------------+                 +------------+
  2.  |           | ReadDBToProp()   |             |  PropToWindow() |            |
  3.  |           | ---------------> |             | --------------> |            |
  4.  |   DB      |                  | Properties  |                 |    Form    |
  5.  |           | SavePropToDB()   |             |  WindowToProp() |            |
  6.  |           | <--------------- |             | <-------------- |            |
  7.  +-----------+                  +-------------+                 +------------+
  8.  
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Commit changes wiith DBEdit
« Reply #20 on: March 11, 2016, 09:11:17 am »
That's easy to to use. But if you still want use a datalayer like DBGrid, memdataset or bufdataset is your answer. Offcourse you can build an own class to hold the properties of your form.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

 

TinyPortal © 2005-2018