Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Annoying cursoradapter
Message
De
25/10/2004 11:53:47
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Annoying cursoradapter
Versions des environnements
Database:
Visual FoxPro
Divers
Thread ID:
00954292
Message ID:
00954292
Vues:
62
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform