Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

Transactions on DBGRID

How I do transactions methods BeginTrans, Rollback and Commit in DBGRID32 Bound a datacontrol.
0
eduguai
Asked:
eduguai
1 Solution
 
clifABBCommented:
You cannot.

There is a problem inherant with all grids that prevent transaction processing.
I have solved this problem in the past by creating a dummy table and moving the data there (which DBGrid reads) then, when done, I move the data back.
0
 
eduguaiAuthor Commented:
I can create workspace variable and work transactions in events  gotfocus and lostfocus,  because the dbgrid first edit and update records
by example
in gotfocus event:
   vworkspace.begintrans

in lostfocus event:
if msgbox(save data ?) = vbyes
   vworkspace.commit
else
   vworkspace.rollback
endif

and procedure in dbgrid unbound for transaccions in
unboundreaddata, unboundwritedata, ...?
0
 
MirkwoodCommented:
I'm sorry for the late answer. Somebody answered it and I missed the question.

Ofcourse you can do it. Here is a sample,
On form_load the transaction is started. Depending on OK/Cancel the changes are commited or revoked.

Private Sub CommandCancel_Click()
    Workspaces(0).Rollback
    Unload Me
End Sub

Private Sub CommandOK_Click()
    Workspaces(0).CommitTrans
    Unload Me
End Sub

Private Sub Form_Load()
    Workspaces(0).BeginTrans
End Sub

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now