Platforms to show: All Mac Windows Linux Cross-Platform

Back to SQLConnectionMBS class.

SQLConnectionMBS.BeginTransaction

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 22.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Begins a transaction.

This method does nothing. Why?
Well, if auto commit is on, you don't need to call this.
If auto commit is off, we call BeginTransaction for you, so if you call this method you would call it a second time and get an error.
We have this method for compatibility to other SQL database classes from Xojo.

SQLConnectionMBS.Disconnect

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 9.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Disconnects the connection from the database.

Closes all commands objects and RecordSets.

SQLConnectionMBS.InsertRecord(TableName as String, Record as Dictionary)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 17.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Convenience function to insert a record.
Example
Var con as SQLConnectionMBS // your database connection

Var d as new Dictionary

d.Value("ID")=2
d.Value("text")="test insert"
d.Value("other")="Just a test"

con.InsertRecord("test_tbl", d)

The plugin builds for you SQL statement with prepared statement and runs the insert command with values.
Lasterror is set or exception raised as with SQLExecute.

Internally this uses a prepared statement. You can check the generated statement via LastStatement property.

SQLConnectionMBS.Listen

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 15.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Start listening for notifications.

Works only for PostgresSQL Client.
Please set client or connect before calling this method.

SQLConnectionMBS.MySQLInsertID as Int64

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns the last auto increment value from last insert command.

Please query value right after doing Insert. This value is reset when you call commit.
For mySQL and MariaDB connections.

see also
http://dev.mysql.com/doc/refman/5.1/en/mysql-insert-id.html

SQLConnectionMBS.Option(name as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
property SQL MBS SQL Plugin 9.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
A string value of a specific connection or command option.
Example
Var c as SQLConnectionMBS // your connection

// for Microsoft SQL use OLEDB, so you don't need native SQL drivers installed...
c.Option("UseAPI") = "OLEDB"
c.Option("SQLNCLI.LIBS") = "sqlsrv32.dll" // Library included in Windows Vista and newer

// for SQLite, set flag to open database file read only:
c.Option("SQLiteVFSFlags") = "1"

// set 10 seconds timeout for MySQL
c.Option("MYSQL_OPT_CONNECT_TIMEOUT") = "10"

// turn on auto cache
c.Option("AutoCache") = "true"

// set connection timeout for ODBC:
c.Option("SQL_ATTR_CONNECTION_TIMEOUT") = "10"

// for mySQL allow multiple RowSets
c.Option("CLIENT_MULTI_STATEMENTS") = "true"
c.Option("CLIENT_MULTI_RESULTS") = "true"

see also:
https://www.sqlapi.com/ApiDoc/class_s_a_connection.html

We have a collection of library files here:
https://www.monkeybreadsoftware.de/xojo/download/plugin/Libs/
(Read and Write computed property)

SQLConnectionMBS.Rollback

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 9.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Cancels any changes made during the current transaction and ends the transaction.

Rollback method rolls back the database to the state it was in at the completion of the last commit operation. All uncommitted work is undone.

Rollback method rolls back the work of all commands that associated with that connection.

To commit all changes made since the start of the transaction use Commit method.

SQLConnectionMBS.UpdateRecord(TableName as String, Record as Dictionary, Keys as Dictionary)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 18.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Convenience function to update a record.
Example
Var con as SQLConnectionMBS // your database connection

Var d as new Dictionary

d.Value("text")="new text"
d.Value("other")="second value"

con.UpdateRecord("test_tbl", d, new dictionary("ID":2))

The plugin builds for you SQL statement with prepared statement and runs the update command with given values for records with given key values.

You can put multiple field names in the keys dictionary.

Lasterror is set or exception raised as with SQLExecute.
Internally this uses a prepared statement. You can check the generated statement via LastStatement property.

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


The biggest plugin in space...