Using Win32OLE library for DAO

I am trying to do something like following to connect to a MS Access db
from
ruby
db = WIN32OLE.new(“DAO.Database”)

but it gives me an error “accessQuery.rb:17:in initialize': unknown OLE server:DAO.Database’ (WIN32OLER
untimeError)”
How can I use DAO object library from ruby?

Thanks in advance,
Jatinder

I could use Database class of DAO by writing following code,

accessApp = WIN32OLE.new(‘Access.Application’)

accessDB = accessApp.CurrentDb()

accessDB is an instance of DAO.Database class.

But is there a way I could use DAO directly?

Regards,

Jatinder

Jatinder S. wrote:

I could use Database class of DAO by writing following code,

accessApp = WIN32OLE.new(‘Access.Application’)

accessDB = accessApp.CurrentDb()

accessDB is an instance of DAO.Database class.

But is there a way I could use DAO directly?

Regards,

Jatinder

Just out of curosity… why do you want to use DAO?

To read Microsoft Access tables data like TableDefs, Tables etc from
Ruby.

Regards,
Jatinder

Hello,
In message “Using Win32OLE library for DAO”
on 06/08/01, “Jatinder S.” [email protected] writes:

I am trying to do something like following to connect to a MS Access db from
ruby
db = WIN32OLE.new(“DAO.Database”)

but it gives me an error “accessQuery.rb:17:in initialize': unknown OLE server:DAO.Database’ (WIN32OLER
untimeError)”
How can I use DAO object library from ruby?

I have not used DAO, but I hope that DAO.DBEngine is what you want.

require ‘win32ole’
WIN32OLE_TYPE.progids.each do |p|
if /dao/i =~ p
puts p
end
end

In my win2k box, the result of above script is:
DAO.DBEngine.36
DAO.PrivateDBEngine.36
DAO.TableDef.36
DAO.Field.36

And
require ‘win32ole’
dao = WIN32OLE.new(‘DAO.DBEngine.36’)
works fine.

Regards,
Masaki S.

I am trying to get an instance of DAO.DataTypeEnum class using Win32OLE
but
it gives the error mentioned before in my earlier email.
Apart from the classes which are listed when ur script is run, there are
other classes under DAO which I want to instantiate and use.

Thanks and Regards,
Jatinder

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs