Ruby can't connect MS access
-
hi, all
I am trying to connect MS access but it always give me an errorError: #<NoMethodError: undefined method `record' for main:Object>
D:/Program Files/Google/Google SketchUp 8/Plugins/testac2.rb:7require 'win32ole' conn = WIN32OLE.new('adodb.connection') record = WIN32OLE.new('adodb.recordset') conn.open " DBQ=data.mdb; DRIVER={Microsoft Access Driver (*.mdb)};" sql = "SELECT username FROM user" record.open( sql, conn ) puts record("username")
It seem "recordset" is't supported by sketchup?, but when I use conn.Open(...) method , it also give me error.
Error: #<WIN32OLERuntimeError: D:/Program Files/Google/Google SketchUp 8/Plugins/access.rb:22:in `method_missing': Open
OLE error code:80040E14 in Microsoft JET Database Engine
FROM 子句语法错误。
HRESULT error code:0x80020009
>
It make me mad, can anyone help? thanksbo cui
-
record
is a reference to an object. You are using it as a method - attempting to pass an argument to it.Maybe line 7 should be:
puts record["username"]
I'm not familiar with accessing Access via Ruby, so I'm only guessing.
Of course with Ruby you don't need to guess at the type of
record
, or what methods it responds to. You can view the type of record usingp record.class
and view its methods using
p record.class.instance_methods(false)
-
thank you,
yes you are right, I used ASP grammar here:(
but I find I also used wrong database driver provider, anyway ,I have worked it out.
Advertisement