Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RecordSet methods don't work with a COMM object
Message
From
15/01/2001 18:22:18
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00463912
Message ID:
00463989
Views:
13
You can directly create the ADO recordset and work with it. For example:
This.oRS = CreateObject("ADODB.Recordset")
With This.oRS
  .Fields.Append("FieldOne", 129, 10)  && 129 = adChar
  .Open
EndWith
Unless 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.

I didn't check the exact syntax so it may not be off by a little.

>If I create a recordset, as in this first snippet, it works as expected - save the snippet as a prg, and run.
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
>ENDDEFINE
But 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
>ENDDEFINE
Now 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.
>
>Any help or suggestions are most appreciated!
Previous
Reply
Map
View

Click here to load this message in the networking platform