Hi!
Looks like Error event should be defined somewhere in the VFPCOM.DLL ;)
Try to use 'ON ERROR' command to define error handler.
>I have a problem with the ADO event WillChangeField and errortrapping in VFP6.
>I have created a class in VFP6 in which I have implemented the RecordSet events with the method BindEvents in VFPCOM.DLL.
>
>When the WillChangeField event fires I cancel the field change by setting the parameter adStatus to 4 (adStatusCancel). When I do this Foxpro generates an error dialog with the error; OLE IDispatch exception code 0 from provider: Operation was canceled... This is ok because I assume the error comes from the recordset because I canceled the field change. To trap the error I add the Error event to my class, but I can't get it to fire.
>
>What am I doing wrong? How can I intercept the error so it doesn't show on the screen?
>
>Code sample:
>loVfpCom = CREATEOBJECT("vfpcom.comutil")
>
>loConnection = CREATEOBJECT("ADODB.Connection.2.5")
>loConnection.ConnectionString = "Provider=SQLOLEDB;Data Source=server;Initial Catalog=data;User ID=sa"
>loConnection.Open()
>
>loRecordSet = CREATEOBJECT("ADODB.Recordset")
>loRecordSet.ActiveConnection = loConnection
>loRecordSet.CursorType = 1 && adOpenKeySet
>loRecordSet.CursorLocation = 3 && adUseClient
>loRecordSet.LockType = 4 && adLockBatchOptimistic
>loRecordSet.Source = "SELECT * FROM table"
>loRecordSet.Open()
>
>loObject = CREATEOBJECT("MyRecordSet")
>loVfpCom.BindEvents(loRecordSet, loObject)
>
>loRecordSet.MoveFirst()
>loRecordSet.Fields(1).Value = "Test"
>
>DEFINE CLASS MyRecordSet AS Custom
>
> PROCEDURE WillChangeField(cFields, Fields, adStatus, pRecordset)
> adStatus = 4 && adStatusCancel
> ENDPROC
>
> PROCEDURE Error(tnError, tcMethod, tnLine)
> ACTIVATE SCREEN
> ?tnError, MESSAGE(), tcMethod, tnLine
> ENDPROC
>ENDDEFINE
>
>TIA
>/Peter
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.comICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs
It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.