Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Possible BUG with CA and delete operations
Message
From
12/06/2004 06:21:37
 
 
To
11/06/2004 05:46:24
Eyvind W. Axelsen
Profdoc Norge As
Oslo, Norway
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Miscellaneous
Thread ID:
00912598
Message ID:
00912996
Views:
17
Hi Eyvind,

Thank you for reporting this issue. As a temporary workaround use CursorAdapter.AfterDelete event as follows:
PROCEDURE AfterDelete 
	LPARAMETERS cFldState, lForce, cDeleteCmd, lResult
	This.DataSource.MoveFirst()
EndProc
Here is "patched" repro code:
CLEAR
CLOSE TABLES ALL 
SET MULTILOCKS ON 

Public loCAdapter As CursorAdapter

Local loCon As ADODB.Connection
loCon = Createobject("ADODB.Connection")
loCon.Open("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Data Source=(local)")

IF MESSAGEBOX("Drop and recreate tables with new set of data?",4)=6
	TRY
	loCon.Execute("DROP TABLE testchild")
	loCon.Execute("DROP TABLE testparent")
	CATCH 
	ENDTRY
	 
	loCon.Execute("create table testparent (id int primary key , descr varchar(20))")
	loCon.Execute("create table testchild (id int primary key , foreignkey int foreign key references testparent (id), somedata varchar(20))")

	loCon.Execute("insert into testparent values (1 ,'Parent1')")
	loCon.Execute("insert into testparent values (2 ,'Parent2')")
	loCon.Execute("insert into testchild values (1 ,1,'Child1')")
	loCon.Execute("insert into testchild values (2 ,1,'Child2')")
	loCon.Execute("insert into testchild values (3 ,2,'Child3')")
	loCon.Execute("insert into testchild values (4 ,2,'Child4')")
ENDIF

loCAdapter = Createobject("catest")
loCAdapter.DataSourceType="ADO"
loCAdapter.Datasource = Createobject('ADODB.RecordSet')
loCAdapter.Datasource.CursorLocation = 3 && adUseClient
loCAdapter.Datasource.LockType = 3 && adLockOptimistic
loCAdapter.BufferModeOverride = 5
loCAdapter.Datasource.ActiveConnection = loCon
loCAdapter.BreakOnError= .T.
loCadapter.Alias = "caTest"

llReturn = loCAdapter.RetrieveData()
If !llReturn
MessageBox(Message())
EndIf 

Select caTest 
LIST
GO top
delete all
if !tableupdate(.T.) 
Messagebox(message())
TABLEREVERT(.T.)
endif

llReturn = loCAdapter.RetrieveData()
If !llReturn
MessageBox(Message())
EndIf 

Select caTest 
LIST


Define Class caTest As cursoradapter

Procedure selectcmd_assign
	Lparameters vNewVal
	This.SelectCmd = Chrtran(m.vNewVal, Chr(13) + Chr(10), "")
EndProc 

Procedure retrievedata()
	Text To this.selectcmd Noshow textmerge
	Select testchild.id, testchild.foreignkey, testchild.somedata,
	testparent.descr
	from testchild, testparent 
	where testparent.id = testchild.foreignkey
	EndText

	this.UpdatableFieldList = "id, foreignkey, somedata"
	this.UpdateNameList = "id testchild.id, foreignkey testchild.foreignkey, somedata testchild.somedata"
	this.Tables = "testchild"
	this.KeyFieldList = "id"

	Return this.CursorFill() 
EndProc

Procedure aftercursorfill
	Lparameters lUseCursorSchema, lnoDataOnLoad, cSelectCmd, lResult
	This.DataSource.Properties("Unique Table") = this.Tables
EndProc

PROCEDURE AfterDelete 
	LPARAMETERS cFldState, lForce, cDeleteCmd, lResult
	This.DataSource.MoveFirst()
EndProc

Enddefine
Thanks,
Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform