Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Class in PRG cannot find parent class
Message
From
03/10/2005 18:20:08
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Class in PRG cannot find parent class
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01055674
Message ID:
01055674
Views:
81
Hi guys,

I'm working on some COM+ server classes. This is in early stages, and is basically an experiment for me.

In the project, I have several PRG's that have my data-access classes defined in them. I wanted to make a generic data access class to base them from, so I added a new prg called bases.prg

Another PRG has a particular class I want to base from the icgdata class in bases.prg, and I can't get it to work. See below code. The specific StmTax class is based on the generic icgdata class. This compiles fine into a COM exe, (or DLL), but I get a 'specified module not found' error when trying to instantiate StmTax. Even if I place both class definitions in the same PRG, that error happens. It does not happen, if I define them each as Session classes, and don't try to subclass anything.




Contents of bases.prg:
&& generic data object
DEFINE CLASS icgdata as Session olepublic 


	Procedure XMLtoData
	Parameters lcXML, lcAlias
	Local loMtx, loContext


	If Empty( lcXML )
* Noting to do
		Comreturnerror("XMLtoDATA","Empty XML string supplied.")
	Else
		Xmltocursor( lcXML, lcAlias )
	Endif

	Endproc


	Procedure DatatoXML
	Parameters lcAlias
	Local loMtx, loContext, lcReturn

	If Empty( lcAlias )
* Nothing to do
		Comreturnerror("DatatoXML","Empty alias supplied.")
	Else
		Cursortoxml( lcAlias, "lcReturn", 1, 1 + 8, 0, "1" )
	Endif


	Return lcReturn



	Endproc
	
	Procedure Error(errornumber, Description, scode, Source, helpfile, HelpContext, fcanceldisplay)

	Comreturnerror(Description,Message())
	Endproc

ENDDEFINE 
Contents of Stmtax.prg, containing child class
Define Class StmTax As icgdata OlePublic

	Procedure Init
	This.MyOpenTables()
	Endproc

	Procedure CreateRec
&& create an empty record and return the record as XML
	Local loMtx, loContext, lcReturn, lnId

* Create a reference to the MTS object
	loMtx = Createobject("MTXAS.APPSERVER.1")
* Create a reference to the Context object
	loContext = loMtx.GetObjectContext()

	Select StmTax
	Append Blank
	=Tableupdate(0,.T.,"StmTax")
	lnId = Myid
	lcReturn = ""

	Select * From StmTax ;
		WHERE (StmTax.Myid == lnId)

	lcReturn = This.DatatoXML(Alias())
* Commit the transaction if there is one
* and tell MTS that we’re done using the component
	loContext.SetComplete()
	Return lcReturn
	Endproc

	Procedure GetEmptyRec
&& create an empty record as XML, without adding anything to the table itself.
	Local loMtx, loContext, lcReturn, lnId

* Create a reference to the MTS object
	loMtx = Createobject("MTXAS.APPSERVER.1")
* Create a reference to the Context object
	loContext = loMtx.GetObjectContext()
	lcReturn = ""

	Select * From StmTax ;
	INTO CURSOR myemptyrec;
		WHERE .F.

	lcReturn = This.DatatoXML("myemptyrec")
	SELECT myemptyrec
	use
* Commit the transaction if there is one
* and tell MTS that we’re done using the component
	loContext.SetComplete()
	Return lcReturn
	Endproc


	Procedure UpdateRec
	Parameters lcXML
	Local loMtx, loContext, lSuccess
* Create a reference to the MTS object
	loMtx = Createobject("MTXAS.APPSERVER.1")

* Create a reference to the Context object
	loContext = loMtx.GetObjectContext()
	This.XMLtoData( lcXML, "MyUpDate" )

	Select StmTax
	Update StmTax Set STM_ID = MyUpDate.STM_ID,;
		OCTOBER = MyUpDate.OCTOBER,;
		NOVEMBER = MyUpDate.NOVEMBER,;
		DECEMBER = MyUpDate.DECEMBER,;
		TAX = MyUpDate.TAX,;
		InitialS = MyUpDate.InitialS,;
		ENT_DATE = MyUpDate.ENT_DATE,;
		LOAD_DATE = MyUpDate.LOAD_DATE,;
		LOADED = MyUpDate.LOADED,;
		EMCODE = MyUpDate.EMCODE,;
		System = MyUpDate.System,;
		LOCATION = MyUpDate.LOCATION,;
		ST = MyUpDate.ST,;
		CNTY = MyUpDate.CNTY,;
		UNIT = MyUpDate.UNIT,;
		TAXYEAR = MyUpDate.TAXYEAR,;
		WCODE = MyUpDate.WCODE,;
		PAYMT_NUM = MyUpDate.PAYMT_NUM,;
		DISC_ID = MyUpDate.DISC_ID;
		WHERE (Myid == MyUpDate.Myid)

	lSuccess = Tableupdate(2,.T.,"STMTAX")

* Commit the transaction if there is one
* and tell MTS that we’re done using the component
	loContext.SetComplete()
	RETURN lSuccess
	Endproc

	Procedure MyOpenTables
	Close Tables
	Set Exclusive Off
	Close Databases
	Set Multilocks On
	Set Deleted On
	Open Database l:\Database\Shared
	Use StmTax In 0 Order Myid
	CursorSetProp("Buffering", 5, "StmTax")

	Endproc

	Procedure Error(errornumber, Description, scode, Source, helpfile, HelpContext, fcanceldisplay)

	Comreturnerror(Description,Message())
	Endproc

	Procedure GetStmTaxbySystem
	Parameters lcSystem
	Local lcReturn, loMtx, loContext
* Create a reference to the MTS object
	loMtx = Createobject("MTXAS.APPSERVER.1")

	loContext = loMtx.GetObjectContext()

	lcReturn = ""

	Select * From StmTax ;
		WHERE (StmTax.System == lcSystem)

	lcReturn = this.DatatoXML(ALIAS())
	loContext.SetComplete()

	Return lcReturn

	Endproc

	Procedure GetStmTaxbyStmIdTaxYear
	Parameters lnStm_Id, lcTaxYear
	Local lcReturn, loMtx, loContext
* Create a reference to the MTS object
	loMtx = Createobject("MTXAS.APPSERVER.1")

	loContext = loMtx.GetObjectContext()

	lcReturn = ""

	Select * From StmTax ;
		WHERE (STM_ID == lnStm_Id);
		AND (TAXYEAR == lcTaxYear)

	lcReturn = this.DatatoXML(ALIAS())
	loContext.SetComplete()

	Return lcReturn

	Endproc

	Procedure GetStmTaxCustom
	Parameters lcWhereClause
	Local lcReturn, loMtx, loContext
* Create a reference to the MTS object
	loMtx = Createobject("MTXAS.APPSERVER.1")

	loContext = loMtx.GetObjectContext()

	lcReturn = ""

	Select * From StmTax ;
		WHERE &lcWhereClause

	lcReturn = this.DatatoXML(ALIAS())
	loContext.SetComplete()
	Return lcReturn

	Endproc



	Function GetRecordCount
	Local loMtx, loContext

	loMtx = Createobject("MTXAS.APPSERVER.1")

	loContext = loMtx.GetObjectContext()

	Select StmTax
	loContext.SetComplete()
	Return Reccount()
	Endfunc

	Procedure XMLtoData
	Parameters lcXML, lcAlias
	Local loMtx, loContext


	If Empty( lcXML )
* Noting to do
		Comreturnerror("stmtax.XMLtoDATA","Empty XML string supplied.")
	Else
		Xmltocursor( lcXML, lcAlias )
	Endif

	Endproc


	Procedure DatatoXML
	Parameters lcAlias
	Local loMtx, loContext, lcReturn

	If Empty( lcAlias )
* Nothing to do
		Comreturnerror("stmtax.DatatoXML","Empty alias supplied.")
	Else
		Cursortoxml( lcAlias, "lcReturn", 1, 1 + 8, 0, "1" )
	Endif


	Return lcReturn


	Endproc



Enddefine
Jim Newsom
IT Director, ICG Inc.
Next
Reply
Map
View

Click here to load this message in the networking platform