sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Ruby can't connect MS access

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 980 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      bigcatln
      last edited by

      hi, all
      I am trying to connect MS access but it always give me an error

      Error: #<NoMethodError: undefined method `record' for main:Object>
      D:/Program Files/Google/Google SketchUp 8/Plugins/testac2.rb:7

      require '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? thanks

      bo cui

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        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 using

        p record.class

        and view its methods using

        p record.class.instance_methods(false)

        Hi

        1 Reply Last reply Reply Quote 0
        • B Offline
          bigcatln
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement