Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Annoying cursoradapter
Message
From
25/10/2004 14:45:46
 
 
To
25/10/2004 11:53:47
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00954292
Message ID:
00954358
Views:
15
Hi David,

Most likely the error "OLE object is invalid or corrupted" is reported because you didn't set data source for Insert/Update/Delete. If you set their data source type to "ADO", they should be set to a valid ADODB.Command object.

The cursor can't be closed because there is a pending change, but the CursorAdapter has been destroyed or detached from the cursor. Simply execute TABLEREVERT(.T.) and the cursor will close.

If TABLEUPDATE() fails, use AERROR function to get the error information.

Thanks,
Aleksey.

>Hello,
>
>At the end of this message is the code from my first try of an updatable CursorAdapter using an OLEDB connection, that I tried to adapt from examples found on the web. That it didn't work wasn't a big surprise for me, but it didn't work in a very annoying way :
>
>The first run goes all the way until it fails with the error "OLE object is invalid or corrupted" on the final USE ; it also doesn't update the table. After this run, the cursoradapter is still shown in my current data session and cannot be closed anymore ; any subsequent run using a cursoradapter fails, and even shutting down VFP fails. The error is always the same : "Cannot update ADODB.Recordset while cursor, created by CursorAdapter.CursorFill method, is not attached to a CursorAdapter object." All I am left with is killing VFP.
>
>No error occurs if I remove the line setting the UpdateCmd property of the CursorAdapter.
>
>So two things could help me a lot : telling me what's wrong in the code below, or telling me how to avoid VFP getting stuck in this situation, so that I could try to debug it by myself without losing one minute at each try.
>
>
>	* loConn is a valid, open ADODB.Connection object
>	loCursorAdapter=CREATEOBJECT("CursorAdapter")
>	lcSql="SELECT * FROM test ORDER BY testid"
>	lcSqlUpdate="UPDATE test SET teststring='test5' WHERE testid=4"
>	WITH loCursorAdapter
>		.Alias="MyAdapter"
>		.DataSourceType="ADO"
>		.DataSource=CREATEOBJECT("ADODB.RecordSet")
>		.InsertCmdDataSourceType="ADO"
>		.UpdateCmdDataSourceType="ADO"
>		.DeleteCmdDataSourceType="ADO"
>		.UpdateCmd=lcSqlUpdate
>		.DataSource.ActiveConnection=loConn
>	ENDWITH
>	SET MULTILOCKS ON
>	loCommand=CREATEOBJECT("ADODB.Command")
>	WITH loCommand
>		.CommandText=lcSql
>		.CommandType=1
>		.ActiveConnection=loConn
>	ENDWITH
>	loRecordSet=CREATEOBJECT("ADODB.RecordSet")
>	WITH loRecordSet
>		.CursorLocation=3
>		.CursorType=3
>		.LockType=3
>		.Source=loCommand
>		.Open()
>	ENDWITH
>	THIS.oCursorAdapter.DataSource.ActiveConnection=THIS.oConnection
>	loCursorAdapter.CursorFill(.F.,.F.,0,loRecordSet)
>	LOCATE FOR testid=4
>	REPLACE teststring WITH "test5"
>	IF TABLEUPDATE()
>		? "TABLEUPDATE"
>	ENDIF
>	loRecordSet.Close()
>	loConn.Close()
>	USE
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform