Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/SQL/SQLDatabaseMBS Microsoft SQL via ODBC on Mac
Function:
Required plugins for this example: MBS MacOSX Plugin, 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/SQLDatabaseMBS Microsoft SQL via ODBC on Mac
This example is the version from Sat, 15th Jun 2018.
Project "SQLDatabaseMBS Microsoft SQL via ODBC on Mac.rbp"
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: // http://www.monkeybreadsoftware.de/xojo/download/plugin/Libs/ // preload libs, this helps on Linux to find them dim libtdsodbc as Folderitem = FindFile("libtdsodbc.dylib") // connect dim con as new SQLDatabaseMBS try // we used Microsoft SQL Server 2008 and run app on Windows to test this dim cs as string = "DRIVER={FREETDS};Server="+iServer.Text+";UId="+iUser.Text+";PWD="+iPass.Text+";Database="+iDatabaseName.Text+";TDS_VERSION=7.2;Port="+iPort.text con.SetFileOption con.kOptionLibraryODBC, libtdsodbc con.Option("UseAPI") = "ODBC" con.DatabaseName = "ODBC:"+cs con.UserName = "" con.Password = "" con.RaiseExceptions = true // if you like to get exceptions instead of checking error property con.Scrollable = false // disabling scrolling cursors is much faster for Microsoft SQL Server... if con.Connect then // add time stamp 'con.SQLExecute "insert into "+iTable.text+" ("+iColumn.text+") VALUES (SYSUTCDATETIME())" // no commit as we have autocommit MsgBox "Connected." // Disconnect is optional // autodisconnect will ocur in destructor if needed con.close end if 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
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.





Links
MBS FileMaker Plugins