Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CursorFill doesn't return an error
Message
 
 
À
21/11/2005 13:12:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01070830
Message ID:
01070851
Vues:
16
>Naomi,
>
>>Where should I place this code? I can not change cursor object class :(
>
>A good option for trapping CursorFill errors is to trap the AfterCursorFill() event and put code there to show an error, log it, and/or set an errormessage property on the adapter. This is covered very well in Doug Hennig's CursorAdapter articles that were in FoxTalk near the end of 2002, where he illustrates calling a HandleError method if the lResult parameter coming into AfterCursorFill is false.
>
>For your specific situation, you could put this into AfterCursorFill() of either your table's subclass or in a higher-level class you're subclassing from:
FUNCTION AfterCursorFill(lUseCursorSchema, lNoData, cSelectCmd, lResult)
>IF NOT lResult
>    AERROR(laError)
>    MessageBox(laError[1,2])
>ENDIF
>RETURN lResult
In my subclasses of CursorAdapter, I do this in AfterCursorFill() and call a HandleError method that sets a cErrorMessage property that can be queried from outside the class. (Of course, we set cErrorMessage = "" in the BeforeCursorFill() method in that case.)

Thanks, David. For now I put it directly in CursorFillMethod, e.g.:
CursorFill (because the AfterCursorFill method is empty in the class. We have a place holder method, but it's also empty)
LPARAMETERS lUseCursorSchema, lNoData, nOptions, uSource
IF NOT PEMSTATUS(THIS, 'lADO_Done', 5)
	THIS.AddProperty('lADO_Done')
ENDIF
IF THIS.DataSourceType = [ADO] AND NOT THIS.lADO_Done
	RETURN
ENDIF
LOCAL llSchema, llNoData, lnOptions, luSource
llSchema  = lUseCursorSchema
llNoData  = lNoData
lnOptions = nOptions
luSource  = uSource
IF VARTYPE(THIS.nFillOptions) <> "N"
	THIS.nFillOptions = -1
ENDIF
IF PCOUNT() < 1 OR VARTYPE(llSchema) <> "L"
	llSchema = THIS.UseCursorSchema
ENDIF
IF PCOUNT() < 2 OR VARTYPE(llNoData) <> "L"
	llNoData = THIS.NoData
ENDIF
IF PCOUNT() < 3 OR VARTYPE(lnOptions) <> "N"
	lnOptions = IIF(THIS.DataSourceType = [ADO], THIS.nFillOptions, 0)
ENDIF
LOCAL llRetVal
IF THIS.DataSourceType = [ADO]
	llRetVal = DODEFAULT(llSchema, llNoData, lnOptions, THIS.oADO_Command)
ELSE
	IF PCOUNT() = 4
		llRetVal = DODEFAULT(llSchema, llNoData, lnOptions, luSource)
	ELSE
		llRetVal = DODEFAULT(llSchema, llNoData, lnOptions)
	ENDIF
ENDIF
NODEFAULT
IF NOT m.llRetVal && There was an error trying to execute CursorFill
    LOCAL laError[1]
	AERROR(laError)
    =ErrorMsg(laError[1,2])
endif    
RETURN m.llRetval
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform