From: "M. Edward (Ed) Borasky" Date: 2007-06-05T21:39:21+09:00 Subject: Re: Using ADO to connect to an Access database in Ruby Andy Robbo wrote: > Thanks very much for all the imput guys, seems like I inadvertantly > posted this question twice in this forum (appologies for that!!!) > > I'm making progress .......... > > #/usr/bin/ruby > > begin > require 'win32ole' > rescue LoadError > puts 'no win32ole available' > exit(1) > end > > require "win32ole" > > ado_con = WIN32OLE.new('adodb.connection') > rs_house = WIN32OLE.new('adodb.recordset') > > ado_con.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" + > base_dir = File.dirname("C:\Documents and Settings\Andy\Desktop") That should be "C:\\Documents and Settings\\Andy\\Desktop" ... '\' is an escape character inside the Ruby double-quoted string, so to ask for one backslash you need to use two of them. What Windows is seeing the way you coded it is "C:Documents and SettingsAndyDesktop". > + > "Alexa.mdb" > > str_sql = "Select * From sample" > > rs_house.open( str_sql, ado_con ) > > print rs_house("sample_URL") > > .................................................................. > > Given my freshness to Ruby at this stage I just want to make sure I can > get access to the database and get something showing on screen. > > I have the OneClick windows installer version of Ruby on my machine, I'm > currently getting this error message when running the code... > > dbtest.rb:15:in `method_missing': open (WIN32OLERuntimeError) > OLE error code:80004005 in Microsoft OLE DB Provider for ODBC > Drivers > [Microsoft][ODBC Microsoft Access Driver] Could not find file > '(unknown)'. > HRESULT error code:0x80020009 > Exception occurred. from dbtest.rb:15 > > ....................................................... > > Can anyone see anything I'm doing which is obviously wrong at this stage > ? > > Many thanks > > Andy > >