Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/SQL/SQLite Encryption Fetch values
Function:
Required plugins for this example: MBS MacOSX Plugin, MBS SQL Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /SQL/SQLite Encryption Fetch values
This example is the version from Thu, 13th Dec 2017.
Project "SQLite Encryption Fetch values.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() // use internal sqlite library call InternalSQLiteLibraryMBS.Use dim con as SQLConnectionMBS dim cmd as SQLCommandMBS try con = new SQLConnectionMBS // connection object // where is the library? 'con.SetFileOption con.kOptionLibrarySQLite, getfolderitem("/usr/lib/libsqlite3.0.dylib", folderitem.PathTypeShell) // connect to database dim f as FolderItem = GetOpenFolderItem("") if f <> nil then #if RBVersion >= 2013 then // Xojo dim path as string = f.NativePath #else // Real Studio dim path as string = f.UnixpathMBS #endif // e.g. "xxx" or "aes128:xxx" or "aes256:xxx" or "rc4:xxx" depending on what you want to use con.SQLiteEncryptionKey = "xxx" con.Connect(path,"","",SQLConnectionMBS.kSQLiteClient) // you need to change the query for your database cmd = new SQLCommandMBS(con, "Select Vorname, Nachname from Addresses") // create command object // Select from our test table cmd.Execute // fetch results row by row and print results while cmd.FetchNext dim Vorname as string = cmd.Field("Vorname").asStringValue dim Nachname as string = cmd.Field("Nachname").asStringValue window1.Listbox1.AddRow Vorname, Nachname wend // commit changes on success con.Commit MsgBox "Rows selected!" end if catch r as SQLErrorExceptionMBS // SAConnection::Rollback() // can also throw an exception // (if a network error for example), // we will be ready try // on error rollback changes if con<>nil then con.rollback end if catch x as SQLErrorExceptionMBS // ignore end try // show error message MsgBox r.message end try End EventHandler
End Class
Class Window1 Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 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:

Feedback, Comments & Corrections

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




Links
MBS Xojo blog