Platforms to show: All Mac Windows Linux Cross-Platform

This item is deprecated and should no longer be used.
/DuckDB/DuckDB test
Function:
Required plugins for this example: MBS DuckDB Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DuckDB/DuckDB test
This example is the version from Tue, 1st Feb 2021.
Project "DuckDB test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open() // no path, so in memory Dim db As New DuckDatabaseMBS Dim con As DuckConnectionMBS = db.Connect // same in one line 'Dim con As New DuckConnectionMBS // create a table If Not con.SQLExecute("CREATE TABLE integers(i INTEGER, j INTEGER);") Then MsgBox con.ErrorMessage Return end if // insert three rows into the table Dim result As DuckResultMBS result = con.SQLSelect("INSERT INTO integers VALUES (3, 4), (5, 6), (7, NULL);") list.AddRow result.ValueString(0,0)+" rows inserted" result = con.SQLSelect("SELECT * FROM integers") For row As Integer = 0 To result.RowCount-1 Dim values() As String For col As Integer = 0 To result.ColumnCount-1 Dim v As String = result.ValueString(col, row) values.Append v Next List.AddRow Join(values, ", ") Next 'Dim rowValues() As Variant = result.RowValues(0) 'Dim colValues() As Variant = result.ColumnValues(1) 'Break Dim p As DuckPreparedStatementMBS = con.Prepare("INSERT INTO integers VALUES (?, ?)") p.BindInt32(1, 42) // the parameter index starts counting at 1! p.BindInt32(2, 43) result = p.SQLSelect list.AddRow result.ValueString(0,0)+" row inserted" // we can also query result sets using prepared statements p = con.Prepare("SELECT * FROM integers WHERE i = ?") p.BindInt32(1, 42) result = p.SQLSelect For row As Integer = 0 To result.RowCount-1 Dim values() As String For col As Integer = 0 To result.ColumnCount-1 Dim v As String = result.ValueString(col, row) values.Append v Next List.AddRow Join(values, ", ") Next End EventHandler
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

Feedback: Report problem or ask question.

The biggest plugin in space...