Platforms to show: All Mac Windows Linux Cross-Platform

/SQL/Microsoft SQL via ODBC on Mac
Required plugins for this example: MBS SQL Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /SQL/Microsoft SQL via ODBC on Mac
This example is the version from Thu, 13th Mar 2019.
Project "Microsoft SQL via ODBC on Mac.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() // you can download libtdsodbc.dylib here: // // preload libs, this helps on Linux/MacOS to find them Dim libtdsodbc As Folderitem = FindFile("libtdsodbc.dylib") dim s as new SoftDeclareMBS #if RBVersion >= 2013 then // Xojo call s.LoadLibrary(libtdsodbc.NativePath) #else // Real Studio call s.LoadLibrary(libtdsodbc.UnixPathMBS) #endif // connect dim con as new SQLConnectionMBS try // we used Microsoft SQL Server 2008 and run app on Windows to test this Dim cs As String = "DRIVER=" cs = cs + libtdsodbc.NativePath cs = cs + ";Server="+iServer.Text+";UId="+iUser.Text+";PWD="+iPass.Text+";Database="+iDatabaseName.Text+";TDS_VERSION=7.2;Port="+iPort.Text con.Option("UseAPI") = "ODBC" con.Connect(cs,"","",SQLConnectionMBS.kODBCClient) con.Scrollable = false // disabling scrolling cursors is much faster for Microsoft SQL Server... // add time stamp dim cmd as new SQLCommandMBS(con, "insert into "+iTable.text+" ("+iColumn.text+") VALUES (SYSUTCDATETIME())") cmd.Execute // no commit as we have autocommit MsgBox "Timestamp saved." // Disconnect is optional // autodisconnect will ocur in destructor if needed con.Disconnect catch r as RuntimeException MsgBox r.message end try End EventHandler
EventHandler Sub Open() if TargetLinux then me.Height = 24 end if End EventHandler
End Control
Control iServer Inherits TextField
ControlInstance iServer Inherits TextField
End Control
Control iPort Inherits TextField
ControlInstance iPort Inherits TextField
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control iUser Inherits TextField
ControlInstance iUser Inherits TextField
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
Control Label4 Inherits Label
ControlInstance Label4 Inherits Label
End Control
Control iPass Inherits TextField
ControlInstance iPass Inherits TextField
End Control
Control Label5 Inherits Label
ControlInstance Label5 Inherits Label
End Control
Control iDatabaseName Inherits TextField
ControlInstance iDatabaseName Inherits TextField
End Control
Control iColumn Inherits TextField
ControlInstance iColumn Inherits TextField
End Control
Control Label6 Inherits Label
ControlInstance Label6 Inherits Label
End Control
Control Label8 Inherits Label
ControlInstance Label8 Inherits Label
End Control
Control iTable Inherits TextField
ControlInstance iTable Inherits TextField
End Control
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
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.

The biggest plugin in space...

MBS Xojo Chart Plugins

Start Chat