HOWTO: Using ADO with a Visual Foxpro DatabaseLast reviewed: February 20, 1998Article ID: Q165492 |
The information in this article applies to:
This article assumes that you are familiar with Microsoft Internet Information Server (IIS) and with creating Active Server Pages (ASP) applications using the programming tools provided with Microsoft Internet Information Server or Microsoft Visual InterDev. Additionally, it assumes that you are familiar with HTML. For more information on Microsoft Information Server and Active Server Pages please see the following Web site:
http://www.microsoft.com/iis/default.asp SUMMARYThis article describes how to use ActiveX Data Objects (ADO) on an Active Server Page (ASP) to access data in a Visual FoxPro database.
MORE INFORMATIONIn order to run Active Server Pages, you must have access to a machine running Microsoft Internet Information Server version 3.0. If you currently have IIS 2.0, you can download IIS 3.0 from the following Web site:
http://www.microsoft.com/iis/default.aspIn order to access a Visual FoxPro database through ADO, you must have the latest Visual FoxPro ODBC driver. For more information about obtaining this driver, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q157767 TITLE : PATCH: Vfpodbc5.exe Visual FoxPro ODBC Driver Version 5.0There are three ways to set up ODBC to access your database over the Internet Information Server:
LimitationsRecordsets, or cursors, generated by Visual FoxPro through the Visual FoxPro ODBC Driver must be of type STATIC, or READONLY. The Visual FoxPro ODBC driver does not support the KEYSET, or DYNAMIC cursor types.
ExampleThis example does not use a specific data source. The connect string is being specified in the connection object's Open method. If you do wish to create and use a Data source, ensure it is a System Data Source on the Microsoft Internet Information Server machine.
Please RememberChange the SourceDB setting to reflect the Tastrade.dbc on the test system. Ensure the Visual FoxPro ODBC driver version 5.0.0.402 is installed on the Microsoft Information Server where this Active Server Page is stored. Please see article reference above for availability options of this driver.
Contents of the ASP Page
<%@ LANGUAGE="VBSCRIPT" %> <HTML> <HEAD> <TITLE>VFP ASP ADO Test</TITLE> </HEAD> <BODY> <H3>ActiveX Data Object (ADO)</H3> <% Set Conn = Server.CreateObject("ADODB.connection") ConnStr= "Driver=Microsoft Visual Foxpro Driver; " + _ "UID=;SourceType=DBC;SourceDB=C:\VFP\Samples\Tastrade\Data\Tastrade.dbc" Conn.Open ConnStr 'This can be a datasource name or a connect string Set cmdTemp = Server.CreateObject("ADODB.Command") Set rs = Server.CreateObject("ADODB.Recordset") SQLText="Select Distinct Products.Product_ID,Products.Product_Name,"+ _ "Products.English_Name,Products.Unit_Price, " + _ "Products.Quantity_In_Unit from Tastrade!Products" cmdTemp.CommandText = SQLText cmdTemp.CommandType = 1 'SQL statement Set cmdTemp.ActiveConnection = Conn rs.CacheSize = 10 rs.Open cmdTemp,,adopenstatic %> <P> <TABLE BORDER=1> <TR> <% For i = 0 to RS.Fields.Count - 1 %> <TD><B><% = RS(i).Name %></B></TD> <% Next %> </TR> <% Do While Not RS.EOF %> <TR> <% For i = 0 to RS.Fields.Count - 1 %> <TD VALIGN=TOP><% = RS(i) %></TD> <% Next %> </TR> <% RS.MoveNext Loop RS.Close Conn.Close %> </TABLE> <BR> <BR> </BODY> </HTML> REFERENCESAdditional information on Active Data Object can be found in the following sources: ADO Web page, http://www.microsoft.com/data/ado/ Visual InterDev online documentation; search on ADO Visual InterDev online documentation; search on Active Server Pages Keywords : FxinteropGeneral FxinteropOdbc vfoxwin kbhowto Version : 3.0 3.0b 5.0 5.0a Platform : WINDOWS Issue type : kbhowto |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |