Platforms to show: All Mac Windows Linux Cross-Platform

/SQL/SQLDatabaseMBS CubeSQL prepared statement


Required plugins for this example: MBS SQL Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /SQL/SQLDatabaseMBS CubeSQL prepared statement

This example is the version from Tue, 13th May 2019.

Project "SQLDatabaseMBS CubeSQL prepared statement.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() // use internal CubeSQL library call InternalCubeSQLLibraryMBS.Use dim db as new SQLDatabaseMBS db.Option("APPNAME") = "Xojo Test" db.Option("ConnectionTimeout") = "5" // 5 seconds timeout? 'db.Option("ConnectionEncryption") = "AES128" // or "AES192" or "AES256" // connect to database // in this example it is CubeSQL, // but can also be Sybase, Oracle, Informix, DB2, SQLServer, InterBase, MySQL, SQLBase and ODBC db.DatabaseName = "cubesql:localhost@mydatabase.sqlite" db.UserName = "admin" db.Password = "admin" db.RaiseExceptions = true // prefer exceptions over checking error if db.Connect then // CREATE TABLE "test" ("test" TEXT, first TEXT, last TEXT) // insert some data dim p1 as SQLPreparedStatementMBS = db.Prepare("INSERT INTO test (test, first, last) VALUES (:test, :first, :last)") p1.Bind("test", "Test") p1.BindType("test", p1.kTypeString) p1.Bind("first", "") p1.BindType("first", p1.kTypeString) p1.Bind("last", "Last") p1.BindType("last", p1.kTypeString) p1.SQLExecute // edit some data dim p2 as SQLPreparedStatementMBS = db.Prepare("UPDATE test SET first=:first WHERE RowID = 1") 'p2.Bind("first", "") p2.Bind("first", "Christian") 'p2.BindType("first", p.kTypeString) p2.SQLExecuteMT db.Commit // Show data dim r as RecordSet = db.SQLSelect("SELECT ROWID,test,first,last FROM test") while not r.EOF window1.List.AddRow r.IdxField(1).StringValue, r.IdxField(2).StringValue, r.IdxField(3).StringValue, r.IdxField(4).StringValue r.MoveNext wend // show version 'dim r as RecordSet = db.SQLSelect("select sqlite_version()") ' 'if r = nil or r.eof then 'MsgBox "Failed to query version." 'else 'MsgBox "Version: "+r.IdxField(1).StringValue 'end if else MsgBox db.ErrorMessage end if End EventHandler
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
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
End Project

See also:

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


The biggest plugin in space...