Acceder a dbf mediante ado

Acceder a dbf mediante ado

Postby jpcavagnaro » Thu Jul 27, 2023 1:54 pm

Hola me podrían decir como hago esta conexión?
Jorge
Saludos.
jpcavagnaro
 
Posts: 155
Joined: Tue Oct 11, 2016 1:02 pm
Location: Luján, bs. as.

Re: Acceder a dbf mediante ado

Postby Cgallegoa » Thu Jul 27, 2023 2:39 pm

Hola Jorge,

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oCn, oRs, aStates

   LOCAL lShowError := .F.

   cPathCnx := "D:\fwh\samples"              
   cSql     := "SELECT * FROM Clients.dbf"

   if ( oCn := FW_OpenAdoConnection( cPathCnx , lShowError ) ) != nil
      if ( oRs   := FW_OpenRecordSet( oCn, cSql ) ) != nil
         oRs:MoveFirst()

         xBrowse(oRs,"oRs")
         oRs:MoveFirst()

         nCol := 1
         aStates := ArrTranspose( oRs:GetRows() )[ nCol ]     // *** Toma sólo la nCol columna. Es decir es un array aStates[n,n] *** //
         oRs:MoveFirst()
         oRs:Close()
      else
         ? "Open Table Fail"
      endif
      oCn:Close()
   else
      ? "Connect Fail"
   endif

return aStates
//--------------------------------------------------------------------------------------//
Saludos,

Carlos Gallego

*** FWH-24.07, xHarbour 1.3.1 Build 20240624, Borland C++7.70, PellesC ***
Cgallegoa
 
Posts: 492
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador

Re: Acceder a dbf mediante ado

Postby jpcavagnaro » Thu Jul 27, 2023 2:57 pm

Carlos, gracias por responder.

le puse lShowError := .t. para que muestre el error y me dice que no se encuentra el especifico el nombre del origen de datos y no se especifico ningún controlador predeterminado.

debo instalar un controlador?
Jorge
Saludos.
jpcavagnaro
 
Posts: 155
Joined: Tue Oct 11, 2016 1:02 pm
Location: Luján, bs. as.

Re: Acceder a dbf mediante ado

Postby nageswaragunupudi » Thu Jul 27, 2023 3:44 pm

No driver or provider need to be installed for using DBFs without FPT files.
The default Jet OLEDB provider that comes bundled with Windows OS is enough.
FWH ADO functions take care of everything for you

Establishing a connection.

Code: Select all  Expand view
oCn := FW_OpenAdoConnection( foldername )


Now all DBF tables (not dbfcdx tables having fpt memo files) are available as tables in this connection.

Open any table with
Code: Select all  Expand view
oRs := FW_OpenRecordSet( oCn, "states" )
to use states.dbf
OR
Code: Select all  Expand view
oRs := FW_OpenRecordSet( oCn, "select first,salary from customer" )


Now deal with the oRs like any other ADO recordset.

For using dbfcdx tables (i.e., dbf tables with fpt memo files), we need to download and install
vfpoledb provider

If you start working we can keep supporting you.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Acceder a dbf mediante ado

Postby jpcavagnaro » Thu Jul 27, 2023 6:54 pm

Mr. Rao, excelente, funciono perfecto.

También necesito usar algunas dbfcdx con memo (dbf y fpt), me podría informar como?
Jorge
Saludos.
jpcavagnaro
 
Posts: 155
Joined: Tue Oct 11, 2016 1:02 pm
Location: Luján, bs. as.

Re: Acceder a dbf mediante ado

Postby nageswaragunupudi » Fri Jul 28, 2023 2:35 am

Download and install VFPOLEDB provider from
https://www.microsoft.com/en-us/downloa ... x?id=32602
and install

After that
open connection object
Code: Select all  Expand view
oCn := FW_OpenAdoConnection( { "FOXPRO", cfoldername }, .T.)

Now you can use DBFCDX dbf files with fpt memo files
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Acceder a dbf mediante ado

Postby jpcavagnaro » Fri Jul 28, 2023 10:28 am

Excelente Mr. Rao.

Entonces, de esta manera, podemos usar de la misma forma sql y dbf solo cambiando la cadena de conexión?

Muchas gracias
Jorge
Saludos.
jpcavagnaro
 
Posts: 155
Joined: Tue Oct 11, 2016 1:02 pm
Location: Luján, bs. as.


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 80 guests