An ADODB Wrapper around the OLEObject framework

  1. 6 years ago

    Alain B

    17 Oct 2013 Europe (Belgium)

    For a project at OneTwo I needed ADODB instead of ODBC to connect to a database. Realbasic/Xojo can do this through the OLEObject, but non of the methods or properties are exposed to the programmer. If you only need it now and then that’s not a real problem, but in some cases you’ll use it all the time. So I decided to write a wrapper around the OLEObjects to make it easier. Also, all available Enums are available (ADOConstants).

    -image-

    You can download the classes from: http://alwaysbusycorner.wordpress.com/2013/10/17/realbasicxojo-an-adodb-wrapper-around-the-oleobject-framework/

    Could you use the Value property in place of directly accessing Attributes?

    I'm wondering if instead of code like this (from ADOConnection):

    return innerConnection.Attributes
    InnerConnection.Attributes = value

    If you could instead do something like this:

    return innerConnection.Value("Attributes")
    InnerConnection.Value("Attributes") = value
  2. John H

    17 Oct 2013 Pre-Release Testers Planet earth

    @Alain B For a project at OneTwo I needed ADODB instead of ODBC to connect to a database. Realbasic/Xojo can do this through the OLEObject, but non of the methods or properties are exposed to the programmer. If you only need it now and then that’s not a real problem, but in some cases you’ll use it all the time. So I decided to write a wrapper around the OLEObjects to make it easier. Also, all available Enums are available (ADOConstants).

    -image-

    You can download the classes from: http://alwaysbusycorner.wordpress.com/2013/10/17/realbasicxojo-an-adodb-wrapper-around-the-oleobject-framework/

    Nice.
    Only problem I have when I try to run it from RS2012R2,1 or Xojo2013R3.1 I get Syntax error: attributes as integer in ADOConnection, ADOField, ADOParameter and ADOProperty.

    I noticed the code try return innerConnection.Attributes // Attributes catch NilObjectException Return -1 catch OLEException Return -1 end try

    The Attributes displaying the blue colour. I wonder if Xojo and RS2012r2.1 see it as one of its own parameter.

  3. Alain B

    17 Oct 2013 Europe (Belgium)

    That is indeed a problem. I hadn't tested it in xojo yet but it does seem Attributes is a xojo keyword. The problem is it can't be renamed because the OLEObject must use this name. If you don't use the Atrributes, Just rename them to something else for the moment until I find a solution for this.

    Thanks for letting me know!

  4. Alain B

    17 Oct 2013 Europe (Belgium)

    1. There seems to be a problem with the ‘Attributes’ property in at least Xojo and RS2012R2.1. Because it is a reserved word. This is very unfortunate because this means the full power of ADODB cannot be used in these versions (unless a Xojo guru has an answer to this). If you do not need these properties but still need other stuff from ADODB, you can remove the Attributes property completely from the following classes:

    ADOConnection, ADOField, ADOParameter, ADOProperty

    Thanks to John Hansen for reporting this.

    2. Also make sure you set the correct path to the Test.mdb file in de demo.
    Just change to conn.ConnectionString = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Test.mdb”

    3. In debug mode, disable ‘Break on Exceptions’ because it stops on every interaction with the OLEObject.

  5. Louis D

    17 Oct 2013 Pre-Release Testers, Xojo Pro QC, Canada

    Just downloaded it. I will try to find some time to test your classes over the weekend. This seems like a very useful and definitely much needed tool.

  6. Paul L

    17 Oct 2013 Xojo Inc Answer http://docs.xojo.com

    Could you use the Value property in place of directly accessing Attributes?

    I'm wondering if instead of code like this (from ADOConnection):

    return innerConnection.Attributes
    InnerConnection.Attributes = value

    If you could instead do something like this:

    return innerConnection.Value("Attributes")
    InnerConnection.Value("Attributes") = value
  7. Alain B

    18 Oct 2013 Europe (Belgium)

    Thank you very much Paul for the solution! Made the changes and it works great on Xojo now. Other problems should be solved also.

    Btw, this is my first topic on the new forum. I have not found how to delete or edit a post yet. Is it possible?

  8. Peter F

    18 Oct 2013 Pre-Release Testers, Xojo Pro New England

    You can edit up until your post is answered or contributed to. Sometimes it requires you to refresh the browser to enable the edit widget. It is accessed in the upper right portion of your post next to the Quote widget.

  9. Alain B

    18 Oct 2013 Europe (Belgium)

    Thanks for the clarification Peter!

  10. Dirk C

    18 Oct 2013 Pre-Release Testers, Xojo Pro Belgium, Zedelgem

    @Alain B Made the changes and it works great on Xojo now

    Has the download been adapted as well? Because if it has been fixed then I need to redownload the file.

  11. Alain B

    18 Oct 2013 Europe (Belgium)

    Yes, you have to download it again, Did mention it in my tweets but forgot to mention it here in the forum :-(

  12. Dirk C

    18 Oct 2013 Pre-Release Testers, Xojo Pro Belgium, Zedelgem

    Thank you :)

  13. Dirk C

    18 Oct 2013 Pre-Release Testers, Xojo Pro Belgium, Zedelgem

    Hey, I just saw that your company is located in Moorslede, Belgium. We're in Meetkerke, Belgium.
    Small world. :)

  14. 3 months ago

    Norman P

    Jun 4 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    Has anyone actually got this still ?

  15. Pierce D

    Jun 4 Pre-Release Testers, Xojo Pro Auckland, New Zealand

    Norman the link is

    Scroll down and download from link Download RAW FTP Dump of RB/Xojo projects

    Extract and look for ADODBWrapper.zip

  16. Norman P

    Jun 4 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    thanks !

or Sign Up to reply!