Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Annoying cursoradapter
Message
From
25/10/2004 12:26:50
 
 
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:
00954311
Views:
11
Hey David,

I'll email you a subclass I created for SQL ADO (I'm assuming you're using SQL). Most of the setup code is in the Init method. Email me if you have any questions. There are just 3 or 4 methods added that you can look at. Also review the Init method.

Aloha,

James
>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