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
-
recordis 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.classand 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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement