Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using VFP Com Object in ASP page
Message
De
26/08/2004 11:17:15
 
 
À
26/08/2004 10:59:02
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00936612
Message ID:
00936634
Vues:
27
Well it works - for a while - then it blows. Why would it work for a while then not work? It doesn't error in the dll. The VBScript in the ASP page returns an error after the 8th page hit. Here is the VBScript error.

Microsoft VBScript runtime error '800a01a8' Object required /includes.asp line 17

Line 17 is:
VALUE="<%=objLocation.Loc_PK "><%=objLocation.Loc_Name

The key is that it fails every 8th time.


Also according to Rick Strahl in this article
http://www.west-wind.com/presentations/aspobjects/aspobjects.htm
it should work.

Look at the last line in the below text. It says Objects can be nested so I assume that refers to a collection.
**********************************

Passing object back from VFP
It's easy to pass objects to your Visual FoxPro server, but it also works the other way around: You can create objects in Visual FoxPro and pass them back to an ASP page.

Here's a simple example of a VFP method that retrieves a record from a table, uses SCATTER NAME MEMO to create an object from the record, and passes it back to ASP:

*******************************************************
* ASPTools :: GetCustObject
*********************************
*** Function: Retrieves customer and returns an object
*** Pass: lcCustId - Cust ID No (no left padding)
*** Return: loCustomer - Customer Object
*******************************************************
FUNCTION GetCustObject
LPARAMETERS lcCustId

IF !USED("TT_Cust")
USE (THIS.cAppStartPath + "data\TT_Cust") IN 0
ENDIF

SELECT TT_Cust

LOCATE FOR CustNo = PADL(lcCustId,8)
IF FOUND()
SCATTER NAME loCustomer MEMO
RETURN loCustomer
ENDIF

SCATTER NAME loCustomer MEMO BLANK
RETURN loCustomer
* WebTools :: GetCustObject

Isn't that cool? Any object you create from within Visual FoxPro is automatically turned into a COM-compatible object that's marshaled back to the calling COM client—ASP in this case. Inside your ASP page you can now simply use that object:

<%
lcCustNo = Request.QueryString("CustNo")

'*** Instantiate VFP Object
SET oServer = Server.CREATEOBJECT("aspdemos.asptools")

'*** Retrieve Customer Object
SET loCustomer = oServer.GetCustObject( (lcCustNo) )
Company: &lt;%= loCustomer.Company   
Name  : &lt;%= loCustomer.CareOf   
Phone : &lt;%= loCustomer.Phone   

Objects can be nested, so you can create a VFP object that contains other member objects, and you can reference those objects and its methods from ASP as well. Powerful, don't you think?


***************************



>As far as I know you can't return a VFP collection class from a com object and use it in ASP. Try returning an ado recordset or an xml string.
>
>>I've created a Multi-Threaded DLL out of the below and installed it in Component Services.
>>If I create the object from an ASP page with VBScript, it runs fine the first 7 or 8 times.
>>Then it consistently returns an error.
>>Help. Is there any reason you can't return a collection and access it from VBScript in the ASP page?
>>Is there anything special I should be doing in the ASP page?
>>
>>
>>DEFINE CLASS Location AS Session OLEPUBLIC
>> NAME = 'Location'
>> cDataPath = "G:\xxx\data\"
>>
>> FUNCTION INIT
>> SET TALK OFF
>> SET RESOURCE OFF
>> SET CPDIALOG OFF
>> SET DELETED ON
>> SET EXACT OFF
>> SET SAFETY OFF
>> SET EXCLUSIVE OFF
>> SET REPROCESS TO 2 SECONDS
>> SYS(2335,0)
>> RETURN
>> ENDFUNC
>>
>> FUNCTION GetLocationList as Object
>> LOCAL loTable AS COLLECTION, loRecord AS OBJECT
>> loTable = CREATEOBJECT("Collection")
>> SELECT Loc_PK, Loc_Name from (this.cdatapath + "LOCATION") into cursor curTEMP
>> SCAN
>> SCATTER NAME loRecord
>> loTable.ADD(loRecord)
>> ENDSCAN
>> RETURN loTable
>> ENDFUNC
>>ENDDEFINE
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform