Skip to content
Paul Lefebvre edited this page Aug 29, 2014 · 2 revisions

Methods

CancelTransaction

Rollback a SQLite transaction that is in process.

ClearLog

Clears the SQL log.

Connect(dbFile As FolderItem, password As String = “”) As Boolean

Connects to the supplied database file. Returns True if the connection was successful, False if it was not.

Storm supports two modes: single database and multiple database

In single database mode, your application uses only a single database. This would be something like iTunes or iPhoto.

In multiple database mode, your application uses a database a document so it may be connected to multiple databases at one time.

This is controlled by the SingleDatabase property.

When SingleDatabase is True, the database will always be created/opened in SpecialFolder.ApplicationData inside a folder with the name of your application. So the StormDemo app will create its database file here:

Mac OS X: ~/Library/Application Support/StormDemo/Baseball.sqlite

Starting with Lion, ~/Library is now a hidden folder so you will have to get to it using the Finder Go To Folder command.

Windows: C:\Users\UserName\AppData\Roaming\StormDemo\Baseball.sqlite

On Windows, AppData is a hidden folder, so you will need to turn on hidden file display in Windows Explorer settings.

If SingleDatabase is False, the database will be created/opened at the location specified by the FolderItem.

Encryption If you would like to encrypt your database when it is created or you would like to connect to a previously encrypted database, supply the password when calling Connect.

Connect(filename As String, password As String) As Boolean

Use this method when SingleDatabase is True to open the database specified in SpecialFolder.ApplicationData (~/Library/Application Support on Mac OS X) by name. Returns True if the connection was successful, False if it was not

Supply the password if your database is encrypted.

EndTransaction

Commits a SQLite transaction that is in process.

Prepare As PreparedSQLStatement

Used to create a PreparedSQLStatement for more secure SQL processing.

SaveLog(logFile As FolderItem) As Boolean

Allows you to save the SQL log to a text file. Saving the log does not clear it.

When the log has been enabled, all SQL commands are captured.

SQLExecute(sqlCommand As String) As Boolean

Sends the supplied sql command directly to the database to be processed. Returns True is the command completed without an error, False if there was an error.

SQLSelect(sqlQuery As String) As RecordSet

Sends the supplied sql query directly to the database and returns a RecordSet.

StartTransaction As Boolean

Begins a SQLite transaction. Returns True if the transaction was started, False if there was a problem.

Vacuum

Performs a SQLite VACUUM DATABASE commend which shrinks the size of the database file by permanently removing any deleted rows from the database.

Properties

Database As REALSQLDatabase (Read-Only)

Gives you direct access to the REALSQLDatabase object. It is best not to use the equivalent methods on DBConnection so that you get logging.

EnableLogging As Boolean

Set this to True to have all SQL statements saved to the internal log. Also see ClearLog and SaveLog.

InTransaction As Boolean (Read-Only)

True when a transaction is in process, False otherwise.

IsConnected As Boolean (Read-Only)

True when DBConnection is actually connected to a database, False otherwise.

LastErrorCode As Integer (Read-Only)

Returns Database.ErrorCode

LastErrorMessage As String (Read-Only)

Returns Database.ErrorMessage

LastRowID As Int64 (Read-Only)

Returns Database.LastRowID

SingleDatabase As Boolean

Set this to True to use only a single database file for your application. Also see Connection for information on how this works.

Updater As DBUpdater

Assign your own DBUpdater subclass to handle database creation and updates.

Shared Properties

Default As DBConnection

Useful for when SingleDatabase is True. Rather than maintaining your own DBConnection property on the App class (or elsewhere) and supplying it to various methods, you can simply use this Shared Property instead and it will be used when a specific connection is not supplied.