Read mdb file
Moderator: Rathinagiri
Read mdb file
Hi friends.
I need to read an Access file (.mdb). I've looked around and there are quite a few things, but... I think the trees do not let me see the forest.
What I want is basic: open the file, read the fields of the different registers to save that information in some variables, and close the file.
A simple example would suffice.
Thank you very much.
I need to read an Access file (.mdb). I've looked around and there are quite a few things, but... I think the trees do not let me see the forest.
What I want is basic: open the file, read the fields of the different registers to save that information in some variables, and close the file.
A simple example would suffice.
Thank you very much.
I get by with a little help from my friends
Re: Read mdb file
Working with .DBF file is very simple through HMG, however, other than DbF file you have to use AdoRDD/SQL
Visit,
http://hmgforum.com/viewtopic.php?f=9&t ... base#p5044
it may help you, there is a good working example from Mustafa
More info on DBF, Access MDB, and SQL database visit
https://db-engines.com/en/system/Micros ... er%3BdBASE
Visit,
http://hmgforum.com/viewtopic.php?f=9&t ... base#p5044
it may help you, there is a good working example from Mustafa
More info on DBF, Access MDB, and SQL database visit
https://db-engines.com/en/system/Micros ... er%3BdBASE
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Read mdb file
Beges,
This may help a little:
As I don't have mdb files I cannot test it!
Serge
This may help a little:
Code: Select all
#include "hmg.ch"
#include "Common.ch"
#include "fileio.ch"
#include "error.ch"
#include "Directry.ch"
#include 'hbclass.ch'
FUNCTION MAIN()
/******************/
PUBLIC oConnexion := OpenConnection("C:\SOME.MDB")
PUBLIC oUser := TUUser()
SET PRINTER TO OUTPUT.TXT
SET PRINTER ON
SET CONSOLE OFF
o := openrecordset( oConnexion, "SELECT * FROM some_mdb_database ")
if o:Recordcount > 0
do while !o:eof()
? o:Fields('some_fld1'):Value
?? o:Fields('some_fld2'):Value
?? o:Fields('some_fld3'):Value
?? o:Fields('some_fld4'):Value
?? o:Fields('some_fld5'):Value
?? o:Fields('some_fld6'):Value
?? o:Fields('some_fld7'):Value
?? o:Fields('some_fld8'):Value
o:MoveNext()
enddo
endif
//o := Execute_Q( oConnexion, "DELETE FROM some_mdb_database WHERE some_fld1 = '??' ")
//o := openrecordset( oConnexion, "INSERT INTO some_mdb_database (some_fld1 , some_fld2) VALUES ('z1', 'z2') ")
o:close()
SET PRINTER TO
SET PRINTER OFF
SET CONSOLE ON
RETURN
CLASS TUUser
/*************/
DATA cKey, cUser, cName INIT ""
DATA nId, nIdAccess INIT 0
END CLASS
Serge
There's nothing you can do that can't be done...
Re: Read mdb file
Thanks, BPD. But now I do not need technical features but a simple and practical example to read an mdb file.bpd2000 wrote: ↑Mon Mar 05, 2018 3:59 am Working with .DBF file is very simple through HMG, however, other than DbF file you have to use AdoRDD/SQL
Visit,
http://hmgforum.com/viewtopic.php?f=9&t ... base#p5044
it may help you, there is a good working example from Mustafa
More info on DBF, Access MDB, and SQL database visit
https://db-engines.com/en/system/Micros ... er%3BdBASE
As for dbf files, I have learned something in the last twenty-five years.
I get by with a little help from my friends
Re: Read mdb file
Thanks, Serge.
I'll try it tonight and then I'll tell you.
I get by with a little help from my friends
- mustafa
- Posts: 1158
- Joined: Fri Mar 20, 2009 11:38 am
- DBs Used: DBF
- Location: Alicante - Spain
- Contact:
Re: Read mdb file
Hola BeGeS:
Mira si te podría servir este sample --> "Adordd_Sample.zip"
viewtopic.php?f=9&t=837&hilit=adordd&start=10
Saludos Mustafa
*------------------------------------- Google --------------------------------------*
Hello BeGeS:
See if you could use this sample -> "Adordd_Sample.zip"
viewtopic.php?f=9&t=837&hilit=adordd&start=10
Regards Mustafa
Mira si te podría servir este sample --> "Adordd_Sample.zip"
viewtopic.php?f=9&t=837&hilit=adordd&start=10
Saludos Mustafa
*------------------------------------- Google --------------------------------------*
Hello BeGeS:
See if you could use this sample -> "Adordd_Sample.zip"
viewtopic.php?f=9&t=837&hilit=adordd&start=10
Regards Mustafa
-
- Posts: 682
- Joined: Tue Jun 04, 2013 6:33 pm
- Location: Argentina
Re: Read mdb file
Hi Mustafa:
I've test your sample posted, but it give an error when compiling, exactly:
APOYO.PRG : USE test.mdb VIA "ADORDD" TABLE "test" alias test
I try compiling under 3.44 and previous versions till 3.40 , and allways the same error.
If you please, tell me how to solve it.-
With regards.
Eduardo
I've test your sample posted, but it give an error when compiling, exactly:
APOYO.PRG : USE test.mdb VIA "ADORDD" TABLE "test" alias test
I try compiling under 3.44 and previous versions till 3.40 , and allways the same error.
If you please, tell me how to solve it.-
With regards.
Eduardo
- mustafa
- Posts: 1158
- Joined: Fri Mar 20, 2009 11:38 am
- DBs Used: DBF
- Location: Alicante - Spain
- Contact:
Re: Read mdb file
Hola EduardoLuis:
He comprobado lo que me dices que está dado Error
he bajado el fichero zip ---> Adordd_Sample.zip
viewtopic.php?f=9&t=837&hilit=adordd&start=10
he utilizado el build.3.4.3.bat que esta dentro del la Carpeta -> [Adordd_Sample]
contenido del fichero bat
*--------------- build.3.4.3.bat ------------------------*
@ECHO OFF
call c:\hmg.3.4.3\build.bat Sample_Adordd.prg %*
*---------------------------------------------------------*
la ruta tie que ser donde este instalado en tu ordenador
HMG 343 he Compilado y no me está dando ningún Error
la compilación tiene que ser en modo de 32 bits.
He probado HMG 344-64 bits y me está dando Error
*---------------- ERROR -------------*
Date:2018-03-06 Time: 12:23:54
Error SQLBASE/1901 Not connected
Called from DBUSEAREA(0)
Called from MAIN(92)
*-------------------------------------*
Creo que es por la mención de:
por el tipo de Driver de Microsoft Access Driver ? no lo se si por que es a 32 bits
Tambien tengo instalado --> Microsoft Office Access 2007
en HMG 343 a 32 bits me funciona y me da Error HMG 344 64 bits
No tengo instalado para probar HMG 344 32 bits
Podría ser el Driver si no está instalado ver:
https://techblog.aimms.com/2014/10/27/i ... ach-other/
https://www.microsoft.com/en-us/downloa ... x?id=13255
Saludos
Mustafa
*------------------------------------------ Google -------------------------------------------*
Hello EduardoLuis:
I have checked what you tell me that is given Error
I have downloaded the zip file ---> Adordd_Sample.zip
viewtopic.php?f=9&t=837&hilit=adordd&start=10
I used the build.3.4.3.bat that is inside the folder -> [Adordd_Sample]
content of the bat file
*--------------- build.3.4.3.bat ------------------------*
@ECHO OFF
call c:\hmg.3.4.3\build.bat Sample_Adordd.prg % *
*---------------------------------------------------------*
the route has to be where this
installed on your HMG 343 computer I have compiled and it is not giving me any error
the compilation has to be in 32-bit mode.
I've tried HMG 344-64 bits and it's giving me Error
*---------------- ERROR -------------*
Date: 2018-03-06 Time: 12:23:54
SQLBASE / 1901 Not connected error
Called from DBUSEAREA (0)
Called from MAIN (92)
*------------------------------------*
I think it's because of the mention of:
by the type of Microsoft Access Driver Driver? I do not know if it's 32 bits
I also have installed -> Microsoft Office Access 2007
in HMG 343 to 32 bits it works for me and it gives me Error HMG 344 64 bits
I do not have installed to test HMG 344 32 bits
It could be the Driver if it is not installed see:
https://techblog.aimms.com/2014/10/27/i ... ach-other/
https://www.microsoft.com/en-us/downloa ... x?id=13255
Regards
Mustafa
He comprobado lo que me dices que está dado Error
he bajado el fichero zip ---> Adordd_Sample.zip
viewtopic.php?f=9&t=837&hilit=adordd&start=10
he utilizado el build.3.4.3.bat que esta dentro del la Carpeta -> [Adordd_Sample]
contenido del fichero bat
*--------------- build.3.4.3.bat ------------------------*
@ECHO OFF
call c:\hmg.3.4.3\build.bat Sample_Adordd.prg %*
*---------------------------------------------------------*
la ruta tie que ser donde este instalado en tu ordenador
HMG 343 he Compilado y no me está dando ningún Error
la compilación tiene que ser en modo de 32 bits.
He probado HMG 344-64 bits y me está dando Error
*---------------- ERROR -------------*
Date:2018-03-06 Time: 12:23:54
Error SQLBASE/1901 Not connected
Called from DBUSEAREA(0)
Called from MAIN(92)
*-------------------------------------*
Creo que es por la mención de:
Code: Select all
RDDSETDEFAULT( "SQLMIX" )
SET( 4, "yyyy-mm-dd" )
RDDINFO( RDDI_CONNECT, { "ODBC", "DBQ=" + "test.mdb;Driver={Microsoft Access Driver (*.mdb)}" } )
DBUSEAREA( .T.,, "select * from test", "test" )
Tambien tengo instalado --> Microsoft Office Access 2007
en HMG 343 a 32 bits me funciona y me da Error HMG 344 64 bits
No tengo instalado para probar HMG 344 32 bits
Podría ser el Driver si no está instalado ver:
https://techblog.aimms.com/2014/10/27/i ... ach-other/
https://www.microsoft.com/en-us/downloa ... x?id=13255
Saludos
Mustafa
*------------------------------------------ Google -------------------------------------------*
Hello EduardoLuis:
I have checked what you tell me that is given Error
I have downloaded the zip file ---> Adordd_Sample.zip
viewtopic.php?f=9&t=837&hilit=adordd&start=10
I used the build.3.4.3.bat that is inside the folder -> [Adordd_Sample]
content of the bat file
*--------------- build.3.4.3.bat ------------------------*
@ECHO OFF
call c:\hmg.3.4.3\build.bat Sample_Adordd.prg % *
*---------------------------------------------------------*
the route has to be where this
installed on your HMG 343 computer I have compiled and it is not giving me any error
the compilation has to be in 32-bit mode.
I've tried HMG 344-64 bits and it's giving me Error
*---------------- ERROR -------------*
Date: 2018-03-06 Time: 12:23:54
SQLBASE / 1901 Not connected error
Called from DBUSEAREA (0)
Called from MAIN (92)
*------------------------------------*
I think it's because of the mention of:
Code: Select all
RDDSETDEFAULT ("SQLMIX")
SET (4, "yyyy-mm-dd")
RDDINFO (RDDI_CONNECT, {"ODBC", "DBQ =" + "test.mdb; Driver = {Microsoft Access Driver (* .mdb)}"})
DBUSEAREA (.T. ,, "select * from test", "test")
I also have installed -> Microsoft Office Access 2007
in HMG 343 to 32 bits it works for me and it gives me Error HMG 344 64 bits
I do not have installed to test HMG 344 32 bits
It could be the Driver if it is not installed see:
https://techblog.aimms.com/2014/10/27/i ... ach-other/
https://www.microsoft.com/en-us/downloa ... x?id=13255
Regards
Mustafa
-
- Posts: 682
- Joined: Tue Jun 04, 2013 6:33 pm
- Location: Argentina
Re: Read mdb file
Hi Mustafa:
I've download the zip and installed on a different folder not inside HMG_3.44
I'll try to do like you.
Thanks
Eduardo
I've download the zip and installed on a different folder not inside HMG_3.44
I'll try to do like you.
Thanks
Eduardo