Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CursorAdapter and 'The BeforeUpdate event has failed' me
Message
De
30/05/2003 17:51:50
 
 
À
30/05/2003 15:24:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00794091
Message ID:
00794782
Vues:
22
>>I don´t know if you tried to do somenthing like that? It looks like a bug in VFP... I don´t know...
>>

Ok. I have to admit there is a problem with error handling inside a grid.

Below is the code that cancels TableUpdate by calling ERROR command from CursorAdapter.BeforeUpdate event.

Everything works fine outside of grid, but in the grid the error is shown twice.
CLOSE DATABASES all
CLEAR
SET MULTILOCKS ON
ON ERROR

CREATE CURSOR foo (f1 I)
INSERT INTO foo values(1)
INSERT INTO foo values(2)
INSERT INTO foo values(3)


LOCAL oCA as CursorAdapter

oCA=CREATEOBJECT("CABeforeUpdateTest")
oCA.DataSourceType="NATIVE"
?oCA.CursorAttach("foo")

* the following lines generate errors (once per line) - 
* ignore those errors
UPDATE foo SET f1=4 WHERE f1=2
SKIP
SKIP 
************************************


LOCAL oForm as Form

oForm=CREATEOBJECT("Form")

oForm.AddObject("oGrid","Grid")
oForm.oGRID.Visible= .T.
oForm.oGrid.RecordSourceType= 1
oForm.oGrid.RecordSource="foo"
oForm.Show(1)


DEFINE CLASS CABeforeUpdateTest AS CursorAdapter
	FUNCTION BeforeUpdate(cFldState, lForce, nUpdateType, cUpdateInsertCmd, cDeleteCmd)
		?PROGRAM()		
		ERROR "You are not allowed to modify the record!"
		RETURN .F.
	ENDFUNC
ENDDEFINE

return
Thanks,
Aleksey.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform