Article Preview
Buy Now
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 theRecordSet
,DatabaseField
, andDatabaseRecord
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
andSQLCommandMBS
. 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 aSQLCommandMBS
as a recordset. We do have the methods for this. The recordset internally has aSQLCommandMBS
object anyway. Similar forSQLDatabaseMBS
class you can request the underlyingSQLConnectionMBS
object if needed. Part of your code can use one interface and another code can use aRecordSet
, 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.