This.oRS = CreateObject("ADODB.Recordset") With This.oRS .Fields.Append("FieldOne", 129, 10) && 129 = adChar .Open EndWithUnless you prefer to work with a VFP cursor, the VFPCOM utility is not needed in your case. Also, some people have reported problems trying to use the VFPCOM utility in COM components.
public o >o = createobject('oTest') >o.makeRS() >?o.oRS.RecordCount && Returns 3 >o.oRS.MoveFirst >?o.ors.fields(0).value && Returns 'One' >o.oRS.MoveLast >?o.ors.fields(0).value && Returns 'Three' > >DEFINE CLASS oTest AS custom &&OLEPUBLIC > oRS = NULL > FUNCTION makeRS > create cursor cTest (FieldOne c(10)) > insert into cTest (fieldone) values ('One') > insert into cTest (fieldone) values ('Two') > insert into cTest (fieldone) values ('Three') > this.oRS = CreateObject("ADODB.Recordset") > > oComUtilClass = create("vfpcom.comutil") > oComUtilClass.CursorToRS(this.oRS) > use in cTest > RETURN > ENDFUNC >ENDDEFINEBut if I create a recordset using a COMM object, and then try to reference the methods, they do not work. For example, regardless of MoveFirst or MoveLast, the Value does not change. To duplicate my problem, save this class definition as a prg, add prg to project, build project as EXE, eg, 'commtest.exe'
DEFINE CLASS oTest AS custom OLEPUBLIC > oRS = NULL > FUNCTION makeRS > create cursor cTest (FieldOne c(10)) > insert into cTest (fieldone) values ('One') > insert into cTest (fieldone) values ('Two') > insert into cTest (fieldone) values ('Three') > this.oRS = CreateObject("ADODB.Recordset") > > oComUtilClass = create("vfpcom.comutil") > oComUtilClass.CursorToRS(this.oRS) > use in cTest > RETURN > ENDFUNC >ENDDEFINENow do the following from the command window
>o = createobject('commtest.otest') && or whatever you called the exe >o.makeRS() >?o.oRS.RecordCount && Returns 3 >o.oRS.MoveFirst >?o.ors.fields(0).value && Returns 'One' >o.oRS.MoveLast >?o.ors.fields(0).value && Returns 'One'>I am trying to figure out how to create a middle-tier object that retrieves data from the database server (Oracle). Then I want to use VFP to instantiate that object, using ADO's RecordSet syntax to manipulate the data.