Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RecordSet methods don't work with a COMM object
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
RecordSet methods don't work with a COMM object
Miscellaneous
Thread ID:
00463912
Message ID:
00463912
Views:
56
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!
Next
Reply
Map
View

Click here to load this message in the networking platform