Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BUG?! in CursorAdapter CursorFill/CursorRefresh methods
Message
From
05/06/2008 06:20:21
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
05/06/2008 05:53:15
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01321806
Message ID:
01321807
Views:
16
Hallo Christian,

I can confirm for VFP 8.0, 9.0SP1 and SP2.

looks like it somehow moves the record pointer what will end up in commiting the data.
I#m always using BufferModeOverride = 5 and explicit check for changes before calling cursorrefresh, so I do not run into that.

Agnes
>Hi everybody,
>
>I just discovered this "behaviour" of the CursorAdapter class, which I think is a serious bug.
>
>If there are uncommited changes to the attached cursor of the CursorAdapter the CursorFill/CursorRefresh methods will silently commit the changes - but only if
>the BuffermodeOverride property is set to 3 (row buffering).
>
>From VFP Help of the CursorRefresh method:
>"Visual FoxPro generates an error message when the cursor contains unsaved changes."
>
>I think this definitly needs a fix, if our application comes into the state that there are uncommited changes when CursorFill/Refresh is called I definitly don't want these changes to be silently committed - instead the error should always be risen and the decision how to deal with this situation should be left to the application developer.
>
>Repro code:
>
>IF !USED('test')
>	CREATE TABLE test (pk I, field1 C(20))
>ENDIF
>
>ZAP IN test
>FOR m.xj = 1 TO 10
>	INSERT INTO test VALUES(m.xj, 'Test ' + TRANSFORM(m.xj))
>ENDFOR
>
>SELECT test
>LOCATE
>
>LOCAL pk_value
>m.pk_value = test.pk
>
>LOCAL loAdapter AS CursorAdapter
>loAdapter = CREATEOBJECT('CursorAdapter')
>loAdapter.DataSourceType = "NATIVE"
>loAdapter.Alias = 'v_test'
>loAdapter.SelectCmd = 'SELECT * FROM test WHERE pk = m.pk_value'
>loAdapter.BufferModeOverride = 3 && change to 5 and the code will raise error 1545 as expected
>loAdapter.SendUpdates = .T.
>loAdapter.Tables = 'test'
>loAdapter.KeyFieldList = 'pk'
>loAdapter.UpdatableFieldList = 'pk, field1'
>loAdapter.UpdateNameList = 'pk test.pk, field1 test.field1'
>
>IF loAdapter.CursorFill()
>
>	replace field1 WITH 'changed' IN v_test
>
>	IF !loAdapter.CursorRefresh()
>	&&IF !loAdapter.CursorFill()
>		AERROR(laError)
>		DISPLAY MEMORY LIKE laError
>	ELSE
>		? 'CursorFill/Refresh succeeded'
>		SELECT test
>		LOCATE FOR pk = m.pk_value && the first CursorFill changes recno
>		? 'Value in Cursor: ' + test.field1
>		? 'Value in CA:     ' + v_test.field1
>	ENDIF
>ELSE
>	AERROR(laError)
>	DISPLAY MEMORY LIKE laError
>ENDIF
>
>
>Christian
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Reply
Map
View

Click here to load this message in the networking platform