Acceder via ADO a foxpro files

Tengo que interrogar una aplicación dos que usa ficheros foxpro dbf y sus cdx. Necesito hacerlo desde ADO, para poder devolver el resultado al Internet Explorer... Me podrias ayudar ?

1 Respuesta

Respuesta
Aqui te va un ejemplo para acceder a una base de datos ( DBC) de Visual Foxpro. Posiblemente puedas adaptarlo a las tablas de foxpro para dos. Olvidate de los indices, ya que deberas hacer una consulta sql
***---- comienza el ejemplo "lista.asp" -----***
<% @LANGUAGE="VBSCRIPT" %>
<% Option Explicit %>
<!--METADATA TYPE="typelib"
uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
<HTML>
<HEAD>
<TITLE>Lista Completa</TITLE>
<!--#INCLUDE FILE="menu1.html"-->
</HEAD>
<BODY BGCOLOR="White" topmargin="10" leftmargin="10" onload="init()">
<!-- Display Header -->
<font size="4" face="Arial, Helvetica">
<br>
<H2 align=center><FONT color=#009900>Lista de Precios</FONT></H2>
<hr size="1" color="Green">
<DIV align=left><PRE><FONT color=#ff0000 size=2><STRONG>Contactenos por Ofertas y condiciones especiales!</STRONG></FONT></PRE></DIV>
<%
Dim oConn
Dim oRs
Dim filePath
Dim Mv
Dim PageNo
Dim j
Dim i
' Map authors database to physical path
filePath = Server.MapPath("datos\truesoft.dbc")
' Create ADO Connection Component to connect with
' sample database
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Driver=Microsoft Visual Foxpro Driver; "+"UID=;SourceType=DBC;SourceDB=" & filePath
' Create ADO Recordset Component
Set oRs = Server.CreateObject("ADODB.Recordset")
' Determine what PageNumber the scrolling currently is on
Mv = Request("Mv")
If Request("PageNo") = "" Then
PageNo = 1
Else
PageNo = Request("PageNo")
End If
' Setup Query Recordset (10 records per page)
oRs.Open "SELECT articulo.codigo,articulo.descrip,articulo.pfinal FROM truesoft!articulo order by codigo", oConn, adOpenStatic
oRs.PageSize = 10
' Adjust PageNumber as Appropriate
If Mv = "Anterior" or Mv = "Siguiente" or Mv = "Home" or Mv = "Inicio" or Mv = "Final" Then
Select Case Mv
Case "Anterior"
If PageNo > 1 Then
PageNo = PageNo - 1
Else
PageNo = 1
End If
Case "Siguiente"
If oRs.AbsolutePage < oRs.PageCount Then
PageNo = PageNo + 1
Else
PageNo = oRs.PageCount
End If
Case "Inicio"
PageNo = 1
Case "Final"
PageNo = oRs.PageCount
Case "Home" %>
<meta http-equiv="refresh" content="0;URL=centro.html">
<%
Case Else
PageNo = 1
End Select
End If
oRs.AbsolutePage = PageNo
%>
<!-- Draw Table of Contacts in DB -->
<TABLE BORDER=1 Bordercolor="Green" width="100%">
<TR>
<TD width="10%" bgcolor="#009900" ><font Color="White" size=-2>Codigo</font></TD>
<TD width="70%" bgcolor="#009900" ><font Color="White" size=-2>Descripcion</font></TD>
<TD width="20%" bgcolor="#009900" ><font Color="White" size=-2>Precio Final</font></TD>
</tr>
<% For j = 1 to oRs.PageSize %>
<TR>
<TD><font size=-1><P align=left><a href="editar.asp?codigo=<%= oRs(0) %>&pagina=<%= PageNo %>"><%= oRs(0) %></a></p></font></TD>
<TD><font size=-1><P align=left><%= oRs(1) %></p></font></TD>
<TD><font size=-1><P align=right><%= oRs(2) %></p></font></TD>
</TR>
<%
oRs.MoveNext
' Don't try to print the EOF record.
If oRs.EOF Then
Exit For
End If
Next %>
</TABLE>
<Form Action=lista.asp Method="POST">
<Input Type="hidden" Name="PageNo" Value="<%= PageNo %>">
<INPUT TYPE="Submit" Name="Mv" Value="Home">
<% If not oRs.EOF Then %>
<INPUT TYPE="Submit" Name="Mv" Value="Siguiente">
<INPUT TYPE="Submit" Name="Mv" Value="Final">
<% End If %>
<% If PageNo > 1 Then %>
<INPUT TYPE="Submit" Name="Mv" Value="Inicio">
<INPUT TYPE="Submit" Name="Mv" Value="Anterior">
<% End If %>
</Form>
</BODY>
</HTML>
***---- finaliza el ejemplo -----***
Recuerda que debes usar ASPs.
Espero te sirva
Saludos
Juan Carlos Biancotti
Pd: No olvides cerrar tu pregunta

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas