WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: spl on June 07, 2024, 12:40:58 PM

Title: Adox class not installed
Post by: spl on June 07, 2024, 12:40:58 PM
This is related to my previous thread regarding creation of a disconnected recordset from a text file. Read no further if it didn't suit 'yer> Ars longa, vita brevis

I had left off with a script to import a disconnected recordset [either xml or adtg] into a pretty nice formatted and typed Excel. I wanted to continue with a script to perform the same into an Access db table, where the access files was created from scratch.

In the old days, ADOX was the method
accdb = dirscript():"testdata.accdb"
cat= CreateObject("ADOX.Catalog")
conn = "Provider=Microsoft.ACE.OLEDB.16.0;Data Source=":accdb
cat.Create(conn)
cat.activeConnection.close()
cat=0
If FileExist(accdb)
  Display(2,"Database Created",accdb)
Else
  Display(2,"Database NOT CREATED",accdb)
Endif

but seems with advent of Win10 and 64bit office and maybe just Microsoft.... this will error with a class not registered even though ADOX is in the registry and if code converted to PS will work fine. So putting that in a WB script returns the error.

So, dig deep into the archives, and this worked...

accdb = dirscript():"testdata.accdb"
If FileExist(accdb) Then FileDelete(accdb)
Display(2,"Creating Access Database",accdb)
application = CreateObject("Access.Application")
application.NewCurrentDataBase(accdb,10)
application.CloseCurrentDataBase()
application.Quit()
If FileExist(accdb)
  Display(2,"Database Created",accdb)
Else
  Display(2,"Database NOT CREATED",accdb)
Endif

and trust me, AI wasn't helpful.
Title: Re: Adox class not installed
Post by: td on June 07, 2024, 01:10:46 PM
On my Windows 11 system, your "ADOX.Catalog" script works just fine. The 64-bit COM server dll is "C:\Program Files\Common Files\System\ado\msadox.dll" and the 32-bit COM server dll is C:\Program Files (x86)\Common Files\System\ado\msadox.dll".

Guess would be that you don't have the 32-bit dll on your system.
Title: Re: Adox class not installed
Post by: spl on June 08, 2024, 02:42:53 AM
My thought too, initially, but both Msadox.dll and Msadox28.tlb are there. I ran a repair on my Office 2016 install and Access Database Engine 2016 - though I doubt those affect Adox. Plan-B I posted is good for now. Thanks for looking.

[EDIT]: For the record, adox snippet works w/64bit WB. And the parameter for the second snippet should be 12, not 10. 10 Creates an .mdb file even if using .accdb extension.
Title: Re: Adox class not installed
Post by: td on June 08, 2024, 06:31:39 AM
If both DLLs are present then the only other explanation is that the 32-bit DLL is not registered. The 32-bit version of the DLL is registered under the WOW6432Node key of the HKEY_CLASSES_ROOT key.