Platforms to show: All Mac Windows Linux Cross-Platform

Database.AddRow(TableName as String, row as DatabaseRow)
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 20.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Inserts Data (a populated DatabaseRow) as a new row in TableName.

Feedback, Comments & Corrections

Database.BeginTransaction
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 20.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Creates a new transaction.
Notes: Changes to the database made after this call can be saved with CommitTransaction or undone with RollbackTransaction.

Feedback, Comments & Corrections

Database.Close
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 1.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Closes or disconnects the database.
Notes:
Calling Close does not issue a Commit, but some databases will automatically Commit changes in a transaction when you Close the connection and some database will automatically Rollback changes in a transaction when the connection is closed. Refer to the documentation for your database to check what its behavior is.

For desktop applications, you will often Connect to the database when the app starts and Close it when the app quits.

For web applications, you usually Connect to the database when the Session starts and Close it when the Session quits.

Feedback, Comments & Corrections

Database.Commit
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 1.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Commits an open transaction. This permanently saves changes to the database.
Notes:
You have to have an open transaction to be able to use Commit. On SQLite (and other databases), you can start a transaction with this command:

BEGIN TRANSACTION

It can be sent using SQLExecute:

DB.SQLExecute("BEGIN TRANSACTION")

Feedback, Comments & Corrections

Database.CommitTransaction
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 20.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Commits an open transaction. This permanently saves changes to the database.

Feedback, Comments & Corrections

Database.Connect
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 20.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Connects to the database so that you can begin using it.

See also:

Feedback, Comments & Corrections

Database.Connect as boolean
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 1.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Connects to the database so that you can begin using it.
Notes:
Before proceeding with database operations, test to be sure that Connect returns True.
If Connect returns False, you should also check the ErrorCode and ErrorMessage.

See Option() for various options you can set before connecting.
e.g. c.Option("SQLiteVFSFlags") = "1" for SQLite for read only access.

See also:

Feedback, Comments & Corrections

Database.ExecuteSQL(sql As String, ParamArray values As Variant)
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 20.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Used to execute an SQL command.
Notes: Use this for commands that do not return any data, such as CREATE TABLE or INSERT.

See also:

Feedback, Comments & Corrections

Database.ExecuteSQL(sql As String, values() As Variant)
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 20.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Used to execute an SQL command.
Notes: Use this for commands that do not return any data, such as CREATE TABLE or INSERT.

See also:

Feedback, Comments & Corrections

Database.InsertRecord(TableName as String, Data as DatabaseRecord)
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 1.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Inserts Data (a populated DatabaseRecord) as a new row in TableName.
Notes: Always check the Error property to verity that the data was added.

Feedback, Comments & Corrections

Database.Prepare(statement as String) as PreparedSQLStatement
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 1.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Creates a PreparedSQLStatement using the SQL statement for use with the various database prepared statement classes.
Notes: A prepared statement is an SQL statement with parameters that has been pre-processed by the database so that it can be executed more quickly if it is re-used with different parameters. Prepared statements also mitigate the risk of SQL injection in web apps.

Feedback, Comments & Corrections

Database.Rollback
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 1.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Cancels an open transaction restoring the database to the state it was in before the transaction began.
Notes:
You will generally want to rollback database changes if a database error occurs within the transaction.
You have to have an open transaction to be able to use Rollback. On SQLite (and other databases), you can start a transaction with this command:

BEGIN TRANSACTION

It can be sent using SQLExecute:

DB.SQLExecute("BEGIN TRANSACTION")

Feedback, Comments & Corrections

Database.RollbackTransaction
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 20.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Cancels an open transaction restoring the database to the state it was in before the transaction began.

Feedback, Comments & Corrections

Database.SelectSQL(sql As String, ParamArray values As Variant) as RowSet
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 20.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Executes a SQL SELECT statement and returns the results in a RowSet.

See also:

Feedback, Comments & Corrections

Database.SelectSQL(sql As String, values() As Variant) as RowSet
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 20.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Executes a SQL SELECT statement and returns the results in a RowSet.

See also:

Feedback, Comments & Corrections

Database.SQLExecute(ExecuteString as string)
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 1.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Used to execute an SQL command. Use this for commands that do not return any data, such as CREATE TABLE or INSERT. ExecuteString contains the SQL statement.
Notes: To avoid SQL Injection, be sure to use Prepared SQL Statements.

Feedback, Comments & Corrections

Database.SQLSelect(SelectString as string) as RecordSet
Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 1.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: This is an SQL statement that returns a RecordSet.
Notes:
SelectString contains the SQL statement.

Typically only SQL SELECT statements return a RecordSet, but some databases return a RecordSet for SQL commands such as INSERT, UPDATE or stored procedures.

If the SQL does not return data then Nil is returned. Nil is also usually returned if there is an error in the SQL statement, but you should instead check Database.Error to check if an error occurred.

To avoid SQL Injection, be sure to use Prepared SQL Statements.

Feedback, Comments & Corrections

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

The biggest plugin in space...




Links
MBS Xojo blog

Start Chat