Recent

Author Topic: Using MS Access with KADao  (Read 1245 times)

ercolesptr

  • New member
  • *
  • Posts: 9
Using MS Access with KADao
« on: November 17, 2022, 04:16:25 pm »
I am trying to use KADao Lazarus component available from here( https://sourceforge.net/projects/ka-dao-for-lazarus/ )in order to use MS Access database with DAO. I installed the components without problem however when I try to make a project and use the components I get an error Class not registered. This error occurs when the program runs after compilation which occurs without errors. The error does not occur when I try to run the executable built but it does not seem to work or maybe I am not using it correctly. Can anyone help please?


ercolesptr

  • New member
  • *
  • Posts: 9
Re: Using MS Access with KADao
« Reply #1 on: November 17, 2022, 04:27:28 pm »
I actually found that the program works well and was able to display the contents of the database in a grid, only thing is that this error occurs at when the program is executed from within lazarus IDE but not when the built exe file is run. Any idea why this is happenening?

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Using MS Access with KADao
« Reply #2 on: November 17, 2022, 05:02:30 pm »
I did this:
- Add a TKADaoDatabase to the form, set its Database property to one of my old Access-97 mdb files, set Connected = true --> ok.
- Add a TKADaoTable to the form, set its Database property to the KADaoDatabase instance added, property TableName lists the names of the tables found in the mdb file, select one of them, set Active = true --> ok.
- Add a TDatasource and a TDBGrid and connect them in the usual way --> DBGrid displays the data of the selected table --> fine!

BUT:
- Trying to compile the project --> Error "Module was not found", raised in TKADaoDatabase.CreateOleDBEngine_II. No idea what's missing... I'm on Win-11. Maybe it does not support DAO any more? But why does it work at designtime?

dseligo

  • Hero Member
  • *****
  • Posts: 1221
Re: Using MS Access with KADao
« Reply #3 on: November 17, 2022, 06:08:44 pm »
I actually found that the program works well and was able to display the contents of the database in a grid, only thing is that this error occurs at when the program is executed from within lazarus IDE but not when the built exe file is run. Any idea why this is happenening?

Maybe your Lazarus is 64-bit and you compile your program to 32-bit or vice versa and you have only 32-bit libraries (or 64-bit in other case).

ercolesptr

  • New member
  • *
  • Posts: 9
Re: Using MS Access with KADao
« Reply #4 on: November 17, 2022, 09:03:13 pm »
Mine gives exception error "class not registered" when running from Lazarus IDE, but works fine otherwise and opens the database in the grid. Any idea how to register that class whichever it is?

ercolesptr

  • New member
  • *
  • Posts: 9
Re: Using MS Access with KADao
« Reply #5 on: November 17, 2022, 09:06:39 pm »
No idea what's missing... I'm on Win-11. Maybe it does not support DAO any more? But why does it work at designtime?

I program with DAO on VB6 and my apps work fine on windows 11, so DAO is still supported.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Using MS Access with KADao
« Reply #6 on: November 17, 2022, 11:03:46 pm »
Mine gives exception error "class not registered" when running from Lazarus IDE, but works fine otherwise and opens the database in the grid. Any idea how to register that class whichever it is?
Some more results from my experiments:

- Desparately I installed KADao in my 64-bit IDE and compiled my test application. Compilation ok, but after start there is now the "class not registered" error that you had reported. Running the application outside the IDE, however, yields a "Cannot find DAO on your system" error.
- Returning to the 32-bit IDE I verified the already reported "Module not found" error inside the IDE. However, when I run the application outside the IDE (I had not done this before) everything is ok now: no error, the DBGrid appears with the expected data...

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: Using MS Access with KADao
« Reply #7 on: November 18, 2022, 09:25:42 am »
AFAIK, there is no DAO 64-Bit
Quote
I program with DAO on VB6
DAO is 32-Bit exclusively.
If your Lazarus is 64-Bit, but you compile to 32-Bit Target.....

Bottom Line: Scrap DAO, and move on
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Using MS Access with KADao
« Reply #8 on: November 18, 2022, 12:26:44 pm »
AFAIK, there is no DAO 64-Bit
Quote
I program with DAO on VB6
DAO is 32-Bit exclusively.
If your Lazarus is 64-Bit, but you compile to 32-Bit Target.....

Bottom Line: Scrap DAO, and move on
Nope, DAO is 32 bit and 64 bit. E.g. if a 64 bit version of Excel or Access is installed, DAO works in 64 bit too.
The limitation is likely using VB6 which is I believe restricted to 32 bit. VB6 was declared legacy in 2008.
See https://learn.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/database-object-dao for examples that work in 32 and 64 bit.. Note that 32 bit will possibly be dropped in the future.

« Last Edit: November 18, 2022, 12:38:56 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: Using MS Access with KADao
« Reply #9 on: November 18, 2022, 01:29:24 pm »
AFAIK, there is no DAO 64-Bit
Quote
I program with DAO on VB6
DAO is 32-Bit exclusively.
If your Lazarus is 64-Bit, but you compile to 32-Bit Target.....

Bottom Line: Scrap DAO, and move on
Nope, DAO is 32 bit and 64 bit. E.g. if a 64 bit version of Excel or Access is installed, DAO works in 64 bit too.
The limitation is likely using VB6 which is I believe restricted to 32 bit. VB6 was declared legacy in 2008.
See https://learn.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/database-object-dao for examples that work in 32 and 64 bit.. Note that 32 bit will possibly be dropped in the future.
Yes, you're right, IF you have Office 64-Bit installed.
I came from OP's comment coming from vb6, and that's definitely 32-Bit
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Using MS Access with KADao
« Reply #10 on: November 18, 2022, 01:48:51 pm »
Yes, you're right, IF you have Office 64-Bit installed.
I came from OP's comment coming from vb6, and that's definitely 32-Bit
You have to jump through hoops to install a 32 bit office nowadays....
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: Using MS Access with KADao
« Reply #11 on: November 18, 2022, 01:53:19 pm »
Yes, you're right, IF you have Office 64-Bit installed.
I came from OP's comment coming from vb6, and that's definitely 32-Bit
You have to jump through hoops to install a 32 bit office nowadays....
since there is still Windows 10 32-Bit available, so is Office 32-Bit. (and yes, Win 11 is 64-Bit only).
If you have to jump through hoops to install Office/Anything 32-Bit on Windows 64-Bit, then you have to decide,
if it's Microsoft's Sales-Department giving good directions to their programmers (to force people to buy a new 64-Bit Office),
or if it's just bad programming on Microsoft's part.
*shrug*
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

ercolesptr

  • New member
  • *
  • Posts: 9
Re: Using MS Access with KADao
« Reply #12 on: November 18, 2022, 03:41:58 pm »
Mine gives exception error "class not registered" when running from Lazarus IDE, but works fine otherwise and opens the database in the grid. Any idea how to register that class whichever it is?
Some more results from my experiments:

- Desparately I installed KADao in my 64-bit IDE and compiled my test application. Compilation ok, but after start there is now the "class not registered" error that you had reported. Running the application outside the IDE, however, yields a "Cannot find DAO on your system" error.
- Returning to the 32-bit IDE I verified the already reported "Module not found" error inside the IDE. However, when I run the application outside the IDE (I had not done this before) everything is ok now: no error, the DBGrid appears with the expected data...

For the class not registered error prompt looks like ticking that "ignore this exception type" checkbox is the only solution, after all it does not occur in the build binary.

With regards to the other error you are getting "Cannot find DAO on your system", I never got that, maybe because I had registered dao360.dll using regsvr32 previously in an effort to remove the "class not registered" error. To do this, do a search on your hard drive for dao360.dll and when you find it open a command prompt in admin mode and go to the path of that dll and type:

regsvr32 dao360.dll

That should remove the bug in win 64

ercolesptr

  • New member
  • *
  • Posts: 9
Re: Using MS Access with KADao
« Reply #13 on: November 22, 2022, 09:03:20 pm »
This link here sheds some more light on the class not registered bug. I know this is for Delphi but I think the fix should work for Lazarus too.

http://mc-computing.com/Databases/delphi/KADao.html

ercolesptr

  • New member
  • *
  • Posts: 9
Re: Using MS Access with KADao
« Reply #14 on: November 23, 2022, 01:30:22 pm »
Also for missing DAO error message it can be fixed by installing one of these:

https://www.microsoft.com/en-us/download/details.aspx?id=10910

 

TinyPortal © 2005-2018