Platforms to show: All Mac Windows Linux Cross-Platform

/SQL/Web app/with SQLConnectionMBS


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 SQLConnectionMBS

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

Project "with SQLConnectionMBS.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 SQLConnectionMBS
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 SQLConnectionMBS.kDB2Client me.AddRow "Firebird" Clients.Append SQLConnectionMBS.kFirebirdClient me.AddRow "Informix" Clients.Append SQLConnectionMBS.kInformixClient me.AddRow "InterBase" Clients.Append SQLConnectionMBS.kInterBaseClient me.AddRow "MySQL" Clients.Append SQLConnectionMBS.kMySQLClient me.AddRow "ODBC" Clients.Append SQLConnectionMBS.kODBCClient me.AddRow "Oracle" Clients.Append SQLConnectionMBS.kOracleClient me.AddRow "PostgreSQL" Clients.Append SQLConnectionMBS.kPostgreSQLClient me.AddRow "SQLBase" Clients.Append SQLConnectionMBS.kSQLBaseClient me.AddRow "SQLite" Clients.Append SQLConnectionMBS.kSQLiteClient me.AddRow "SQLServer (Microsoft)" Clients.Append SQLConnectionMBS.kSQLServerClient me.AddRow "Sybase" Clients.Append SQLConnectionMBS.kSybaseClient 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 SQLConnectionMBS // 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 integer = clients(PopupClient.SelectedRowIndex) if client <> SQLConnectionMBS.kSQLiteClient then MessageBox "We only allow here SQLite here." Return end if dim cDatabase as string = iDatabase.text dim cUsername as string = iUserName.text dim cPassword as string = iPassword.text c.Connect cDatabase, cUsername, cPassword, client Session.db = c SQLPage.show Exception s as runtimeexception MessageBox s.message End EventHandler
End Control
Control Label5 Inherits WebLabel
ControlInstance Label5 Inherits WebLabel
End Control
Property Clients() As Integer
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 co as new SQLCommandMBS co.setCommandText sql co.Connection = Session.db co.Execute 'List.ColumnCount = co.FieldCount dim c as integer = co.FieldCount-1 for x as integer = 1 to c dim field as SQLFieldMBS = co.field(x) List.HeaderAt(x-1) = field.name next while co.fetchnext list.AddRow co.field(1).asStringValue for x as integer = 2 to c List.CellTextAt(List.LastAddedRowIndex, x) = co.field(x).asStringValue Next wend Exception r as runtimeexception MessageBox r.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...