Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorAdapter data in a Grid RecordSource
Message
 
 
To
23/03/2004 10:29:08
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00888525
Message ID:
00888875
Views:
10
The variable loDO loses scope once the INIT code finishes running. Once that happens the CA object is also destroyed and the cursor associated with the CA is also closes. You could make loDO a publica variable [least desired way], or you can add a property to the form to hold the object reference to the CA. Something like:
THISFORM.AddProperty('oGridSource')
THISFORM.oGridSource = Createobject("CursorAdapter")
WITH THISFORM.oGridSource
   .DataSourceType="ODBC"
   .alias="ODBC_CCS"
   .Datasource=Sqlstringconnect(CONNECTION_STRING)
   .SelectCmd="select * from  supervisores"
   .CursorFill()
ENDWITH
THIS.RecordSource="ODBC_CCS"
I would have my CONNECTION_STRING defined as a constant in a header file. That way, you only need to change the string in the header file instead of hunting through all your forms, code, etc., to change it in all locations.

In the Destroy of the Form, you need the following code:
IF PEMSTATUS('THIS', 'oGridSource', 5)
   THIS.oGridSource = .null.
ENDIF
My preference would be to create a generic CA class in a VCX and add that CA to the DE of the form. You can populate your properties there and let the form handle the creation and destruction of the CA.
Mark McCasland
Midlothian, TX USA
Previous
Reply
Map
View

Click here to load this message in the networking platform