Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 14.1 ('Barcodes')
Instant purchase and download via GumRoad!

FEATURE

The MBS SQL Plugin

An alternative way to connect to databases

Issue: 14.1 (January/February 2016)
Author: Christian Schmitz
Author Bio: Christian Schmitz is the creator of the Monkeybread Software Xojo Plugins.
Article Description: No description available.
Article Length (in bytes): 24,034
Starting Page Number: 24
Article Number: 14105
Related Web Link(s):

http://www.connectionstrings.com

Excerpt of article text...

While Xojo ships with a couple of database plugins for various database vendors, some developers have special needs. For example with SQLite there could be a newer version of the SQLite library or one with special extensions compiled in like encryption. Some developers related to geography use spatialite, a special version of SQLite with additional commands and functions to work with geo coordinates. Others may simply want to have more low level options or simply a support for a database which is not directly available in Xojo like DB2.

The MBS SQL Plugin is an alternative interface to databases in Xojo. It has two sides: First, the SQLDatabaseMBS class, which is a subclass of Xojo's database class. This makes it a perfect drop-in replacement for the built in Xojo database plugins. You can simply use the RecordSet, DatabaseField, and DatabaseRecord classes. But as you use Xojo's database class, you must have the database license.

The second side is the native plugin interface with classes like SQLConnectionMBS and SQLCommandMBS. They provide much more functionality and more options for the various databases. And those classes work without a Xojo database license unless you use RecordSet class.

While you can decide for using SQLConnectionMBS class as your interface, you can still use RecordSets by requesting a SQLCommandMBS as a recordset. We do have the methods for this. The recordset internally has a SQLCommandMBS object anyway. Similar for SQLDatabaseMBS class you can request the underlying SQLConnectionMBS object if needed. Part of your code can use one interface and another code can use a RecordSet, for example to use with reporting classes.

Using SQLDatabaseMBS

Lets just start connecting to a database with MySQL and run a query. As you will see, the usage is very similar to one of the built-in Xojo database classes. First you need a new instance of the database class, so you write a line like this:

...End of Excerpt. Please purchase the magazine to read the full article.