MBS Xojo Developer Conference and Training
Join us from 3rd to 6th May 2017 in Berlin, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

SQLConnectionMBS class

class, SQL, MBS SQL Plugin (SQL), class SQLConnectionMBS,
Plugin version: 9.3, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: The class for a SQL Plugin Database connection.
dim con as new SQLConnectionMBS


// where is the library?
con.SetFileOption con.kOptionLibraryMySQL, SpecialFolder.UserHome.Child("libmysqlclient.dylib")

// connect to database
// in this example it is Oracle,
// but can also be Sybase, Informix, DB2
// SQLServer, InterBase, SQLBase and ODBC

dim server as string = ""


MsgBox "We are connected!"

// Disconnect is optional
// autodisconnect will ocur in destructor if needed

msgbox "We are disconnected!"

catch r as RuntimeException
MsgBox r.message

// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready

// on error rollback changes

catch rr as runtimeexception
MsgBox rr.message
end try
end try
Supported databases: Oracle, Microsoft SQL Server, DB2, Sybase, Informix, InterBase/Firebird, SQLBase, MySQL, PostgreSQL and ODBC and SQLite.

With Xojo 2013r1, you only need a database server license from Xojo, Inc. if you use the SQLDatabaseMBS class. The SQLConnectionMBS class does not require this license. But some features like getting a recordset do need the license as they refer to the SQLDatabaseMBS class.

Please free all RecordSets and SQLCommand objects before you close the SQLConnection or the SQLDatabase. The plugin keeps references from RecordSets and SQLCommand to prevent automatic destruction of the database connection. If you close a database connection while you have RecordSets and SQLCommand in use, things may go wrong.

The plugin can cache the recordset locally. To enable you can call SQLCommandMBS.Cache or use the Option("AutoCache") = "true" on either command or connection or database objects. The plugin will than fetch all records and store them in memory. After this you can walk over the recordset and use FetchPos, FetchFirst, FetchLast, FetchPrev and FetchNext to locate the rows you need. When you call Field() you always get last row, but to read from cached result set, please use Value() function. When using RecordSet, the values are read via Value() functions automatically.

You can use InternalPostgreSQLLibraryMBS or InternalSQLiteLibraryMBS if you like to use our built in SQLite or PostgreSQL database libraries.

This class has no sub classes.

Some methods using this class:

Some properties using for this class:

Some events for this class:

Some examples which use this class:

The items on this page are in the following plugins: MBS SQL Plugin.

SQLCommandMBS   -   SQLDatabaseMBS

Bilder aus Nickenich