Article ID: 165492 - Last Review: March 8, 2005 - Revision: 4.7 How to use ADO with ASP to display Visual FoxPro dataThis article was previously published under Q165492
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 about Microsoft
Information Server and Active Server Pages, see the following Web
site:
http://www.microsoft.com/iis
(http://www.microsoft.com/iis)
On This PageSUMMARY
This article describes how to use ActiveX Data Objects (ADO) on an Active
Server Page (ASP) to access data in a Microsoft Visual FoxPro database.
MORE INFORMATION
To run Active Server Pages, you must have access to a computer
that is running Microsoft Internet Information Server (IIS) version 3.0 or a later version of IIS.
To access a Visual FoxPro database through ADO, you must have the
latest Visual FoxPro ODBC driver. For additional information about how to obtain this driver, click the following article number to view the article in the Microsoft Knowledge Base: 277772
(http://support.microsoft.com/kb/277772/
)
Visual FoxPro ODBC Driver not included in MDAC 2.6 and later
Note If your database or tables use any of the features that were introduced in Visual FoxPro 7.0 or a later version of Visual FoxPro, you must use the VFP OLE DB Provider to connect to the data. To obtain the VFP OLE DB Provider, visit the following Microsoft Developer Network (MSDN) Web site: http://www.msdn.microsoft.com/vfoxpro
(http://www.msdn.microsoft.com/vfoxpro)
To set up ODBC to access your database over the
Internet Information Server, use one of the following methods:
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 computer.RememberChange the SourceDB setting to reflect the Tastrade.dbc on the test system. Ensure the Visual FoxPro ODBC driver version 6.01.8629.01 or later 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>
REFERENCES
Additional information on Active Data Object can be found in the following
sources:
APPLIES TO
| Article Translations
|
Back to the top
