views:

486

answers:

5

If I have a base windows xp system, ruby and an ms access 2007 file (say c:/foo/bar.accdb) file, what's the least intrusive method for reading that .accdb file.

  • What needs to be installed on the xp system.
  • What is the specific connection string.
+1  A: 

You could use ADO via Ruby's win32ole library.

Complete details and code can be found here.

David Mullet
A: 

If you can use ADO then you will find the ADO libraries already installed on a Windows XP box (otherwise distribute MDAC). Then all you need is the ACE dlls plus its OLE DB Provider, available for free from the Microsoft Download Center:

2007 Office System Driver: Data Connectivity Components

onedaywhen
+1  A: 

You may use the Ruby library Sequel (http://sequel.rubyforge.org/documentation.html) , it has ADO adapter

Arnaud
A: 

As this blog post explains it (Ruby on Windows: Using Ruby & ADO to Work with MS Access Databases, you can use ADO to connect to the MS Access 2007 database.

xav0989
+1  A: 

Something along these lines should get you started. Of course, you'll need to modify some of the values like; path, filename, SQLstatement, etc.

require 'win32ole'
connection = WIN32OLE.new('ADODB.Connection')
connection.Open('Provider=Microsoft.Jet.OLEDB.4.0;
                 Data Source=c:\path\filename.mdb')

To execute a SQL query that doesn't return data use:
connection.Execute("INSERT INTO Table VALUES ('Data1', 'Data2');")

To perform a query that returns a recordset:
recordset = WIN32OLE.new('ADODB.Recordset')
recordset.Open(SQLstatement, connection)
KevenDenen