Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorAdapter and 'The BeforeUpdate event has failed' me
Message
From
02/06/2003 16:03:54
 
 
To
02/06/2003 15:26:54
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00794091
Message ID:
00795390
Views:
19
>Hi Aleksey,
>just to let you know...
>the problem that I mentioned I solved in this way:
>
>Instead of this code in BeforeUpdate event:
>
>IF valorunitario = 0
> MESSAGEBOX( "Valor não pode ser zero")
> RETURN .F.
>ENDIF
>
>I am using this code:
>
>IF valorunitario = 0
> cUpdateInsertCmd = "RAISERROR('Valor nao pode ser zero',16,1)"
>ENDIF
>
>So, I replace the command that VFP will send to SQL, raising the error there. It work if you use ODBC.
>

Hi Ricardo,

I've modified my code to use RAISERROR and I still have the same issue with the grid - the error is shown twice.
There is no difference in behavior between sending RAISERROR to the server and calling ERROR command locally.
What am I missing? How do you suppress extra error message in the grid?


Modified code:
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="ODBC"
oCA.DataSource=SQLCONNECT("LocalServer")
?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!"
		cUpdateInsertCmd="RAISERROR('You are not allowed to modify the record!',16,1)"
		RETURN .F.
	ENDFUNC
ENDDEFINE
Thanks,
Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform