Platforms to show: All Mac Windows Linux Cross-Platform
/SQL/SQLDatabaseMBS SQLite uuid
Required plugins for this example: MBS SQL Plugin
Last modified Thu, 11th Jun 2025.
You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /SQL/SQLDatabaseMBS SQLite uuid
Download this example: SQLDatabaseMBS SQLite uuid.zip
Project "SQLDatabaseMBS SQLite uuid.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
// use internal sqlite library with UUID extension
InternalSQLiteLibraryMBS.UUIDExtensionEnabled = True
Call InternalSQLiteLibraryMBS.Use
Var db As New SQLDatabaseMBS
// where is the library?
'db.Option(SQLConnectionMBS.kOptionLibrarySQLite) = "/usr/lib/libsqlite3.0.dylib"
// connect to database
// in this example it is SQLite,
// but can also be Sybase, Oracle, Informix, DB2, SQLServer, InterBase, MySQL, SQLBase and ODBC
Var path As String = ":memory:" // in-memory database without a file
db.RaiseExceptions = true
db.DatabaseName = "sqlite:"+path
If db.Connect Then
// make an uuid
Var r As RowSet = db.SelectSQL("SELECT uuid()")
MessageBox "uuid: " + r.ColumnAt(0).StringValue
r = nil
// create table with uuid id field
db.SQLExecute "CREATE TABLE Test(id TEXT PRIMARY KEY DEFAULT (uuid()), FirstName TEXT, LastName TEXT)"
// insert value
db.SQLExecute "INSERT INTO Test(FirstName, LastName) VALUES ('Bob', 'Jones')"
db.SQLExecute "INSERT INTO Test(FirstName, LastName) VALUES ('John', 'Smith')"
db.SQLExecute "INSERT INTO Test(FirstName, LastName) VALUES ('Anna', 'Miller')"
db.SQLExecute "INSERT INTO Test(FirstName, LastName) VALUES ('Diana', 'Doe')"
Var rec As RowSet = db.SelectSQL("SELECT * FROM Test")
Var list As Listbox = SQLWindow.List
While Not rec.AfterLastRow
list.AddRow rec.Column("id"), rec.Column("FirstName"), rec.Column("LastName")
rec.MoveToNextRow
Wend
rec = Nil
// list schemas
If False then
r = db.SelectSQL("PRAGMA database_list;")
While Not r.AfterLastRow
list.AddRow r.ColumnAt(1)
r.MoveToNextRow
Wend
r = Nil
end if
// dump the database
Var lines() As String = InternalSQLiteLibraryMBS.DumpToStrings(db.SQLiteConnectionHandle, "main", "")
SQLWindow.TextArea1.Text = string.FromArray(lines, EndOfLine)
End If
End EventHandler
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Sign
End Sign
Class SQLWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
End Control
End Class
End Project
See also:
- /SQL/SQLDatabaseMBS CubeSQL prepared statement
- /SQL/SQLDatabaseMBS Microsoft SQL via ODBC on Linux
- /SQL/SQLDatabaseMBS MySQL Connect
- /SQL/SQLDatabaseMBS MySQL Fetch values
- /SQL/SQLDatabaseMBS ODBC Connect
- /SQL/SQLDatabaseMBS PostgreSQL
- /SQL/SQLDatabaseMBS PostgreSQL Connect
- /SQL/SQLDatabaseMBS SQLite Encryption Fetch values
- /SQL/SQLDatabaseMBS SQLite Fetch values threaded
- /SQL/SQLDatabaseMBS SQLite Test
Download this example: SQLDatabaseMBS SQLite uuid.zip
The items on this page are in the following plugins: MBS SQL Plugin.