HOWTO: Visual FoxPro Automation Servers and Active Server Pages

Last reviewed: July 30, 1997
Article ID: Q168053
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 5.0, 5.0a

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. 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" %>
         <!-- Ensure that there is a space before LANGUAGE and
    
              after "VBSCRIPT" -->
         <HTML>
         <HEAD>
         <TITLE> VFP and ASP </TITLE>
         </HEAD>
    
         <BODY>
         <H2>Active Server Pages and Visual FoxPro Automation Servers</H2>
    
         <%Set VFPSrv = Server.CreateObject("ASPSrv.WristWatch")%>
    
         Today's Date is <%=VFPSrv.GetDate()%>
         <P>
         The Current Time is <%=VFPSrv.GetTime()%>
    
         </BODY>
         </HTML>
    
    

  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.
Keywords          : FxinteropOle vfoxwin kbinterop kbtool kbhowto
Technology        : kbole
Version           : 5.0 5.0a
Platform          : WINDOWS


================================================================================


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.

Last reviewed: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.