Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid's record issue
Message
From
10/02/2001 09:06:08
 
 
To
09/02/2001 15:47:09
Chuck Tripi
University of Wisconsin - Milwaukee
Milwaukee, Wisconsin, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00474589
Message ID:
00474711
Views:
39
Hi Chuck.

>> Yes, I am using buffering, =TableUpdate(.T.), and =TableRevert(.T.). I will look into that "multi-records" TableRevert, I didn't even know about it! <<

PMFJI, but =TableUpdate( .T. ) is not a good way to code this. The TABLEUPDATE() function returns a value and should should check to see what it has returned in case an error has occurred. Something like this:
IF NOT TABLEUPDATE( 1, .F., 'MyAlias' )
   *** An error occurred. Find out what it was
   IF NOT This.HandleError()
      RETURN .F.
   ENDIF
ENDIF
HandleError method should look something like this:
LOCAL laErrors[1], llRetVal, loUpd, lnMsgNo
llretVal = .T.

AERROR( laErrors )
DO CASE
CASE laErrors[1] = 1539		&& Trigger failed
   DO CASE
      CASE laErrors[5] = 1	&& Insert Trigger
	MESSAGEBOX( 'Insert Trigger Failed', 16, 'Unable to Insert Record' )
	llRetVal = .F.
      CASE laErrors[5] = 2	&& Update Trigger
	MESSAGEBOX( 'Update Trigger Failed', 16, 'Unable to Update Record' )
	llRetVal = .F.
      CASE laErrors[5] = 3	&& Delete Trigger
	MESSAGEBOX( 'Delete Trigger Failed', 16, 'Unable to Delete Record' )
	llRetVal = .F.
   ENDCASE	

CASE laErrors[1] = 1585		&& Update Conflict
   *** Instantiate the upodate conflict handler to handle the conflict
   loUpd = CREATEOBJECT( 'updres', ThisForm.DataSessionID, .cPrimaryTable )
   IF TYPE( 'loUpd' ) = "O" AND ! ISNULL( loUpd )
      loUpd.Show()
   ENDIF
   llRetVal = .T.

CASE laErrors[1] = 1884		&& Duplicate key	
   MESSAGEBOX( 'Duplicate Key', 16, 'Unable to Save Record' )
   llRetVal = .F.

OTHERWISE
   MESSAGEBOX( 'Unknown Problem', 16, 'Unable to Save Record' )
   llRetVal = .F.
ENDCASE							
RETURN llRetVal				


Code like this will make your application a little bit more robust.

Marcia
Previous
Reply
Map
View

Click here to load this message in the networking platform