Platforms to show: All Mac Windows Linux Cross-Platform

/SQL/Web app/with SQLDatabaseMBS


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/Web app/with SQLDatabaseMBS

This example is the version from Mon, 6th Nov 2022.

Project "with SQLDatabaseMBS.xojo_binary_project"
Class App Inherits WebApplication
EventHandler Sub Opening(args() as String) Call InternalSQLiteLibraryMBS.Use End EventHandler
End Class
Class Session Inherits WebSession
Const ErrorDialogCancel = "Do Not Send"
Const ErrorDialogMessage = "This application has encountered an error and cannot continue."
Const ErrorDialogQuestion = "Please describe what you were doing right before the error occurred:"
Const ErrorDialogSubmit = "Send"
Const ErrorThankYou = "Thank You"
Const ErrorThankYouMessage = "Your feedback helps us make improvements."
Const NoJavascriptInstructions = "To turn Javascript on, please refer to your browser settings window."
Const NoJavascriptMessage = "Javascript must be enabled to access this page."
Property db As SQLDatabaseMBS
End Class
Class ConnectPage Inherits WebPage
Control Label1 Inherits WebLabel
ControlInstance Label1 Inherits WebLabel
End Control
Control Label2 Inherits WebLabel
ControlInstance Label2 Inherits WebLabel
End Control
Control Label3 Inherits WebLabel
ControlInstance Label3 Inherits WebLabel
End Control
Control Label4 Inherits WebLabel
ControlInstance Label4 Inherits WebLabel
End Control
Control PopupClient Inherits WebPopupMenu
ControlInstance PopupClient Inherits WebPopupMenu
EventHandler Sub Opening() me.AddRow "DB2" Clients.Append "DB2" me.AddRow "Firebird" Clients.Append "Firebird" me.AddRow "Informix" Clients.Append "Informix" me.AddRow "InterBase" Clients.Append "InterBase" me.AddRow "MySQL" Clients.Append "MySQL" me.AddRow "ODBC" Clients.Append "ODBC" me.AddRow "Oracle" Clients.Append "Oracle" me.AddRow "PostgreSQL" Clients.Append "PostgreSQL" me.AddRow "SQLBase" Clients.Append "SQLBase" me.AddRow "SQLite" Clients.Append "SQLite" me.AddRow "SQLServer (Microsoft)" Clients.Append "SQLServer" me.AddRow "Sybase" Clients.Append "Sybase" End EventHandler
End Control
Control iDatabase Inherits WebTextField
ControlInstance iDatabase Inherits WebTextField
End Control
Control iUserName Inherits WebTextField
ControlInstance iUserName Inherits WebTextField
End Control
Control iPassword Inherits WebTextField
ControlInstance iPassword Inherits WebTextField
End Control
Control ConnectButton Inherits WebButton
ControlInstance ConnectButton Inherits WebButton
EventHandler Sub Pressed() if PopupClient.SelectedRowIndex < 0 then MessageBox "Please select a client type." Return end if dim c as new SQLDatabaseMBS // you can place the database client library files where you want. // example code just has some convenient location for testing. 'c.Option(c.kOptionLibrarySQLite) = "/usr/lib/libsqlite3.0.dylib" 'c.SetFileOption c.kOptionLibraryMySQL, SpecialFolder.UserHome.Child("libmysqlclient.dylib") 'c.SetFileOption c.kOptionLibraryPostgreSQL, GetFolderItem("libpq.dylib") Dim client As String = clients(PopupClient.SelectedRowIndex) if client <> "SQLite" then MessageBox "We only allow here SQLite here." Return end if c.UserName = iUserName.Text c.Password = iPassword.Text c.DatabaseName = client+":"+iDatabase.Text if c.Connect then Session.db = c SQLPage.show else MessageBox "Failed to connect: "+c.ErrorMessage end if Exception s as runtimeexception MessageBox s.message End EventHandler
End Control
Control Label5 Inherits WebLabel
ControlInstance Label5 Inherits WebLabel
End Control
Property Clients() As string
End Class
Class SQLPage Inherits WebPage
Control List Inherits WebListBox
ControlInstance List Inherits WebListBox
End Control
Control QueryButton Inherits WebButton
ControlInstance QueryButton Inherits WebButton
EventHandler Sub Pressed() #pragma BreakOnExceptions false List.RemoveAllRows dim sql as string = iSQL.text dim r as RecordSet = Session.db.SQLSelect(sql) if Session.db.Error then MessageBox Session.db.ErrorMessage else 'List.ColumnCount = r.FieldCount dim c as integer = r.FieldCount-1 for x as integer = 1 to c dim field as DatabaseField = r.IdxField(x) List.HeaderAt(x-1) = field.name next while not r.EOF list.AddRow r.IdxField(1).StringValue for x as integer = 2 to c List.CellTextAt(List.LastAddedRowIndex, x) = r.IdxField(x).StringValue next r.MoveNext wend end if Exception rr as runtimeexception MessageBox "Exception: "+rr.message End EventHandler
End Control
Control iSQL Inherits WebTextField
ControlInstance iSQL Inherits WebTextField
End Control
Control Label1 Inherits WebLabel
ControlInstance Label1 Inherits WebLabel
End Control
End Class
Sign
End Sign
End Project

See also:

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


The biggest plugin in space...