Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursosAdapter dettached cursor not so dettached
Message
From
23/10/2003 16:16:05
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
CursosAdapter dettached cursor not so dettached
Miscellaneous
Thread ID:
00841809
Message ID:
00841809
Views:
46
Hi.

Adapting some code to do a demo of some classes using the Nortwind database I found a couple issues with CusorAdapters. Here's the repro code:
Clear

Local ;
 oCA as CursorAdapter, ;
 oCon as ADODB.Connection, ;
 oRS as ADODB.RecordSet, ;
 oXA as XmlAdapter, ;
 lcReturn as String, ;
 oError as Exception
 
* ADO Connection to SQL's Northwind (change the server to test)
oCon = CreateObject("ADODB.Connection")
oCon.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" ;
 + "User ID=sa;Initial Catalog=Northwind;Data Source=saliasmovil"
oCon.Open()

* New recordset
oRS = CreateObject("ADODB.RecordSet")
oRS.ActiveConnection = oCon

* New CA pointing to the Recordset - populate from Orders
oCA = CreateObject("CursorAdapter")
oCA.DataSourceType="ADO"
oCA.DataSource = oRS
oCA.SelectCmd = "select * from Orders"
oCA.CursorFill()

* I detach the cursor and everything is OK
? oCA.CursorDetach()
* I kill the RS and CA (assuming the cursor stands now on its own)
oRS = null
oCA = null

* If I close the connection here, I can't do the ##ToXml## bellow
* (Comment out the next line and it WORKS)
oCon.Close() 
oCon = null

lcReturn = ""
oXA = CreateObject( "XmlAdapter")
oXA.AddTableSchema( Alias() )
Try
	* Here ##ToXml## blows 
	oXA.ToXML( "lcReturn" )		
Catch to oError
	? oError.ErrorNo
	? oError.Message
	? oError.Details 
EndTry

MessageBox( lcReturn )
What I see is that I assumed that once dettached, the cursor was in fact indepent from the underlying recordset. I can workaround this as I can close everything AFTER generating the XML... in this situation.

Any comments or opinions appreciated.

See you,
Next
Reply
Map
View

Click here to load this message in the networking platform