DOCUMENT:Q168053 21-FEB-2002 [foxpro] TITLE :HOWTO: Use VFP Automation Servers with Active Server Pages PRODUCT :Microsoft FoxPro PROD/VER::5.0,5.0a,6.0 OPER/SYS: KEYWORDS:kbinterop kbAutomation kbvfp500 kbvfp600 ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, versions 5.0, 5.0a, 6.0 ------------------------------------------------------------------------------- SUMMARY ======= Microsoft Internet Information Server (IIS) 3.0 supports Active Server Pages (ASP). ASPs allow you to perform server-side processing and scripting through the use of automation servers, including automation servers that were created in Visual FoxPro 5.0 or 6.0. This article demonstrates how to use a Visual FoxPro automation server with Active Server Pages. MORE INFORMATION ================ There are primarily two components: - Visual FoxPro Automation Server. - Active Server Page that instantiates the server. The Visual FoxPro Automation Server ----------------------------------- For this example, you can create a simple automation server in Visual FoxPro. This automation server has two methods: one called GetTime(), which will return the current time and one called GetDate(), which will return the current date. Creating the automation server: 1. Create a new project named ASPSrv in Visual FoxPro. 2. Add a new program to the project with the following code: DEFINE CLASS WristWatch AS Custom OLEPUBLIC PROCEDURE GetTime() RETURN Time() ENDPROC PROCEDURE GetDate() RETURN Date() ENDPROC ENDDEFINE 3. Build the project into an OLE DLL automation server. 4. Install the automation server onto your IIS 3.0 server. NOTE: It is recommended that you use the Setup Wizard in Visual FoxPro as a distribution method. Files that will be included for distribution are the Visual FoxPro runtime, the OLE server .DLL, .TLB, and .VBR files. The Active Server Page ---------------------- The ASP file is the component that instantiates the automation server and calls the methods of the automation server. 1. Create the following file in a text editor, such as Notepad: <%@ LANGUAGE="VBSCRIPT" %> VFP and ASP

Active Server Pages and Visual FoxPro Automation Servers

<%Set VFPSrv = Server.CreateObject("ASPSrv.WristWatch")%> Today's Date is <%=VFPSrv.GetDate()%>

The Current Time is <%=VFPSrv.GetTime()%> 2. Save this file to your IIS WWWROOT directory as VFPSrv.ASP, and make certain that this directory has Execute privileges. 3. You should now be able to access this Active Server Page from your Web browser. The page should show the current date and time from the server. Additional query words: ====================================================================== Keywords : kbinterop kbAutomation kbvfp500 kbvfp600 Technology : kbVFPsearch kbAudDeveloper kbVFP500 kbVFP600 kbVFP500a Version : :5.0,5.0a,6.0 Issue type : kbhowto ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2002.