An ADODB Wrapper around the OLEObject framework

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).

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

[quote=40950:@Alain Bailleul]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).

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

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.

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!

  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.

  1. 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”

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

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.

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

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?

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.

Thanks for the clarification Peter!

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

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

Thank you :slight_smile:

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

Has anyone actually got this still ?

Norman the link is

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

Extract and look for ADODBWrapper.zip

thanks !