ADO con Dbase

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
claudiotedesco
Posts: 132
Joined: Thu Jul 31, 2008 12:05 pm

ADO con Dbase

Post by claudiotedesco »

Hola Gente

Mi consulta es la siguiente, puedo habrir una base DBF con ADODB.Connection, para luego hacer un query asi lo cargo en un grid
Yo segun me habian indicado en otros topic se puede con MDB que me funciono perfecto, ahora quisiera saber si se puede directamente con DBF.
Si tiene un ejemplo de como hacer la coneccion se los agradezco.
Saludos y gracias.
Claudio
User avatar
Vanguarda
Posts: 543
Joined: Wed Feb 11, 2009 10:56 am
Location: Americana - SP
Contact:

Re: ADO con Dbase

Post by Vanguarda »

Hi friend,

I think that for working with DBF is very better use the commands in xBase standard.

Anyway, i think that is possible open a file DBF in ADO but a not have knowledge for explain it for you (the friend luisvasquezcl, know very well about how to make it).

But I think improvement way of working with DBF is the standard xbase.

Regards,

Sorry my bad english
--
Paulo Sérgio Durço (Vanguarda)


http://hmglights.wordpress.com/
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: ADO con Dbase

Post by luisvasquezcl »

Paulo, thanks for your words 8).
Hola Claudio, es posible abrir practicamente cualquier base de datos con ado o con odbc.
Si necesitas abrir archivos dbf creo que es mejor utilizar las funciones nativas del lenguaje y los controles dedicados a ello, asi ganaras en velocidad y facilidad en la codificacion.
Si quieres intentarlo aqui te adjunto la cadena de conexion:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\folder;Extended Properties=dBASE III;User ID=Admin;Password=;
Espero te sea de ayuda
Saludos cordiales
Luis Vasquez

Hi Claudio, you can open virtually any database with ADO or ODBC.
If you need to open files dbf I think it's better use the native language and controls involved in this and win in the speed and ease coding.
If you want to try here the connection string attached:


Hi Claudio, you can open virtually any database with ADO or ODBC.
If you need to open files dbf I think it's better use the native language and controls involved in this and win in the speed and ease coding.
If you want to try here the connection string attached:

I hope you be of help
Best regards
Luis Vasquez
claudiotedesco
Posts: 132
Joined: Thu Jul 31, 2008 12:05 pm

Re: ADO con Dbase

Post by claudiotedesco »

Hola Luis
Quise intertar abrir una DBF con ADO pero me esta dando error.
el Error es el siguiente
Error ADODB.Connection/0 S_OK: OPEN
Called from TOLEAUTO:OPEN(0)
Called from MAIN(24)


Adjunto codigo para ver si esta correcto como lo hice
Gracias

#include <minigui.ch>
#include 'adodb.ch'

Function Main
Local nOption := 0
Local oConexion, oTable

Set DAte British
Set Century On
Set Navigation Extended

oConexion = TOleauto():New('ADODB.Connection')

oConexion:ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +;
'Data Source=D:\Documents%20and%20Settings\CLAUDIO1\Escritorio\Nueva%20carpeta\ADO;'+;
'Extended Properties=dBASE III;' +;
'User ID=Admin;Password=;'

oConexion:Open()

oSql := "SELECT PARR.NOMC, PARR.DIRT, PARR.TELT FROM PARR"
oTable := TOleAuto():New('ADODB.Recordset')
oTable:CursorLocation = adUseClient
oTable:Open(oSql , oConexion, adOpenDynamic, adLockOptimistic )

if oTable:State = adStateClose
Msgstop('FALLA EN LA APERTURA DE LA TABLA')
Return
Endif

Load Window Main
Main.Center
Main.Activate
Return

procedure load( otbl )
Main.grid_1.deleteallitems
if oTbl:recordcount > 0
oTbl:Movefirst()
do while !oTbl:eof()
main.grid_1.additem( { oTbl:fields('NOMC'):value,;
oTbl:fields('DIRT'):value,;
oTbl:fields('TELT'):value })
otbl:movenext()
enddo
oTbl:Movefirst()
endif
main.grid_1.value := 1
main.grid_1.setfocus
return


procedure statuscontrols(n, otbl)
if n = 2 .and. oTbl:Recordcount = 0
msgstop('Grid dont have records')
return
endif
Main.Grid_1.Setfocus
return
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: ADO con Dbase

Post by luisvasquezcl »

Hola Claudio

aqui te dejo el ejemplo funcionando. las tablas test.dbf;test.dbt debes alojarlas en el siguiente path c:\varios

Espero te sirva.
Saludos cordiales,
Luis Vasquez
Attachments
Varios.zip
Sample Ado with DBF
(2.35 KiB) Downloaded 448 times
claudiotedesco
Posts: 132
Joined: Thu Jul 31, 2008 12:05 pm

Re: ADO con Dbase

Post by claudiotedesco »

Gracias LUIS me funciono, excelente tu ayuda.
Claudio
Post Reply