Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/SQL/SQLDatabaseMBS Microsoft SQL cross platform
Function:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /SQL/SQLDatabaseMBS Microsoft SQL cross platform
This example is the version from Sat, 15th Jun 2018.
Project "SQLDatabaseMBS Microsoft SQL cross platform.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() dim db as SQLDatabaseMBS = Connect // continue here with db 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 Connect() As SQLDatabaseMBS // connect to Microsoft SQL Database Dim con As New SQLDatabaseMBS dim cs as string dim user as string = iUser.Text dim pass as string = iPass.Text dim databaseName as string = iDatabaseName.text dim server as string = iServer.text dim Port as string = iPort.Text #if TargetLinux then // install package tdsodbc cs = "DRIVER={libtdsodbc.so};Server="+Server+";UId="+User+";PWD="+Pass+";Database="+DatabaseName+";TDS_VERSION=7.2;Port="+Port con.DatabaseName = "ODBC:"+cs con.Option("UseAPI") = "ODBC" #elseif TargetWin32 then cs = Server + "@"+DatabaseName con.UserName = User con.Password = Pass con.Option("OLEDBProvider") = "SQLNCLI" con.DatabaseName = "SQLServer:"+cs #elseif TargetMacOS then dim libtdsodbc as Folderitem = FindFile("libtdsodbc.dylib") // download library on MBS website: // http://monkeybreadsoftware.de/xojo/download/plugin/Libs/ cs = "DRIVER={FREETDS};Server="+Server+";UId="+User+";PWD="+Pass+";Database="+DatabaseName+";TDS_VERSION=7.2;Port="+Port con.SetFileOption con.kOptionLibraryODBC, libtdsodbc con.Option("UseAPI") = "ODBC" con.DatabaseName = "ODBC:"+cs #else ? #endif // DB Library settings con.Option("DBPROP_INIT_TIMEOUT") = "10" con.Option("DBPROP_COMMANDTIMEOUT") = "10" // ODBC settings con.Option("SQL_ATTR_QUERY_TIMEOUT") = "10" con.Option("SQL_ATTR_CONNECTION_TIMEOUT") = "10" if con.ConnectMT then con.Scrollable = True // if you like to get exceptions instead of checking error property con.RaiseExceptions = false return con Else dim e as string = con.errorMessage System.DebugLog e Break end if End Function
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