Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Database Transaction statement madness
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Database Transaction statement madness
Miscellaneous
Thread ID:
00875488
Message ID:
00875488
Views:
64
Hello. I've been having problems using the begin transaction, txnlevel, and end transaction statements. The controls on my form are bound to a view. A new record is being added to the table, but whenever the requery(nameoftheview) statement executes, the new record does not appear on the form nor the view. Below is the code i'm using as well as some of my comments. This application is running on a server, although I'm testing it on a stand alone pc. Are these transaction statements necessary. Any help would be greatly appreciated. Thanks.

BEGIN TRANSACTION
IF .Adding
lcCntrlNbr = NewCntrlNbr("OMHSAS", "OmhSasCorrespondence")
IF LEN(ALLTRIM(lcCntrlNbr)) != 13
ROLLBACK
=MESSAGEBOX( ;
"A control number was not generated for this " + ;
"OMHSAS correspondence record. You can " + ;
"try again or cancel the addition.", ;
MB_OK + MB_ICONEXCLAMATION, ;
"OMHSAS Control Number")
RETURN .F.
ELSE
REPLACE ;
lvOmhSasCorrespondence.cCntrlNbr ;
WITH lcCntrlNbr ;
IN lvOmhSasCorrespondence
ENDIF
REPLACE ;
(lcAlias + ".cAddedBy") WITH OmhSasCorr.rcEmpNbr, ;
(lcAlias + ".tAddDate") WITH DATETIME() ;
IN (lcAlias)
ELSE
REPLACE ;
(lcAlias + ".cUpdatedBy") WITH OmhSasCorr.rcEmpNbr, ;
(lcAlias + ".tLastUpd") WITH DATETIME() ;
IN (lcAlias)
ENDIF

IF TABLEUPDATE(0, .F., lcAlias)
IF TXNLEVEL() != 0
END TRANSACTION
ENDIF
SELECT (lcAlias)

******* AT this point, I started debugging the code, and the new record was added to ******* the view.
.rcKey = EVALUATE(lcAlias + ".cCntrlNbr")
******* When the following statement executes, I browsed the view and the new record ******* was not in the view and didn't appear on the form, but it made it to the table.
=REQUERY("lvOmhSasCorrespondence")
SET NEAR ON
=SEEK(.rcKey, lcAlias, "CntrlNbr")
If EOF(lcAlias)
LOCATE
ENDIF
STORE .F. TO .Adding, .Updating
.SetAccess()
.ModeCancel()
ELSE
SELECT (lcAlias)
IF TXNLEVEL() != 0
ROLLBACK
ENDIF
.Error()
ENDIF
Next
Reply
Map
View

Click here to load this message in the networking platform