I can create the cursor in a class but can't see it on my form. I am trying to simulate extracting data from an MSSQL data container into an adorecordset then into a cursor that I can read. If i put code in prg without the define clas then works ok - but i need in a class (COM) as other programmers using diff language will use this. How can I see the cursor created in vfp. Here is code that creates class and gets cursor:
DEFINE CLASS disbdescrfile as Custom olepublic
PROCEDURE getcode
* this procedure verifies existance of a code and returns .T. if exists, .F. if doesn' exist.
LPARAMETERS lccode
SELECT id FROM descr WHERE ALLTRIM(id)=ALLTRIM(lccode) INTO CURSOR tempdescr
IF _tally=0
RETURN .F.
ELSE
RETURN .T.
endif
PROCEDURE getdisbdescrfile
LOCAL loConn AS ADODB.CONNECTION, ;
loCommand AS ADODB.COMMAND, ;
loException AS EXCEPTION, ;
loCursor AS CURSORADAPTER
** ADO
loConn = CREATEOBJECT('ADODB.Connection')
WITH loConn
.ConnectionString = 'Provider = VFPOLEDB; Data Source = ESILaw.DBC'
.OPEN()
ENDWITH
loCommand = CREATEOBJECT('ADODB.Command')
loCommand.ActiveConnection = loConn
** Put the result (RecordSet) into a VFP cursor
loCursor = CREATEOBJECT('CursorAdapter')
WITH loCursor
.ALIAS = 'Descr'
.DATASOURCETYPE = 'ADO'
.SELECTCMD = ;
'SELECT * FROM Descr WHERE type="D"'
.DATASOURCE = CREATEOBJECT('ADODB.Recordset')
.DATASOURCE.ActiveConnection = loConn
llReturn = .CURSORFILL(.F., .F., 0, loCommand)
ENDWITH
RETURN
enddefine
here is small prg I am using to test getting the cursor back to vfp:
myvar1=CREATEOBJECT("disbdescrfile.disbdescrfile")
myvar1.getdisbdescrfile()
SELECT descr && I have tried (myvar1.locursor) (myvar1)
BROWSE normal
What do I need on the select - or is it even possible or do we have to return the adorecordset to vfp then create cursor?
DEFINE CLASS disbdescrfile as Custom olepublic
PROCEDURE getcode
* this procedure verifies existance of a code and returns .T. if exists, .F. if doesn' exist.
LPARAMETERS lccode
SELECT id FROM descr WHERE ALLTRIM(id)=ALLTRIM(lccode) INTO CURSOR tempdescr
IF _tally=0
RETURN .F.
ELSE
RETURN .T.
endif
PROCEDURE getdisbdescrfile
LOCAL loConn AS ADODB.CONNECTION, ;
loCommand AS ADODB.COMMAND, ;
loException AS EXCEPTION, ;
loCursor AS CURSORADAPTER
** ADO
loConn = CREATEOBJECT('ADODB.Connection')
WITH loConn
.ConnectionString = 'Provider = VFPOLEDB; Data Source = ESILaw.DBC'
.OPEN()
ENDWITH
loCommand = CREATEOBJECT('ADODB.Command')
loCommand.ActiveConnection = loConn
** Put the result (RecordSet) into a VFP cursor
loCursor = CREATEOBJECT('CursorAdapter')
WITH loCursor
.ALIAS = 'Descr'
.DATASOURCETYPE = 'ADO'
.SELECTCMD = ;
'SELECT * FROM Descr WHERE type="D"'
.DATASOURCE = CREATEOBJECT('ADODB.Recordset')
.DATASOURCE.ActiveConnection = loConn
llReturn = .CURSORFILL(.F., .F., 0, loCommand)
ENDWITH
RETURN
enddefine
here is small prg I am using to test getting the cursor back to vfp:
myvar1=CREATEOBJECT("disbdescrfile.disbdescrfile")
myvar1.getdisbdescrfile()
SELECT descr && I have tried (myvar1.locursor) (myvar1)
BROWSE normal
What do I need on the select - or is it even possible or do we have to return the adorecordset to vfp then create cursor?