Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/SQL/SQLDatabaseMBS MSSQL Execute
Function:
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/SQLDatabaseMBS MSSQL Execute
This example is the version from Sat, 9th Jan 2015.
Project "SQLDatabaseMBS MSSQL Execute.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() dim db as new SQLDatabaseMBS db.Option("UseAPI") = "OLEDB" DB.Option("SQLNCLI.LIBS") = "sqlsrv32.dll" // Library included in Windows Vista and newer // connect to database // in this example it is Mirosoft SQL Server, // but can also be Sybase, Informix, DB2 // Oracle, InterBase, SQLBase and ODBC // server format should be: // PcName\SqlServerInstanceName@DatabaseName db.DatabaseName="SQLServer:WINDOWS7PC\SQLEXPRESS@test" db.UserName="" db.Password="" db.RaiseExceptions = true if db.Connect then // We are connected! db.AutoCommit = db.kAutoCommitOff db.Scrollable = false // show version of server 'dim con as SQLConnectionMBS = db.Connection 'MsgBox "Server Version: "+con.ServerVersionString // do a query 'dim r as RecordSet = db.SQLSelect("select * from TestTable") 'while not r.EOF 'MsgBox r.IdxField(1).StringValue 'r.MoveNext 'wend // update a value 'db.SQLExecute "UPDATE TestTable SET vorname='test' WHERE id=4" // insert something and query id of auto_increment db.SQLExecute "INSERT INTO TestTable (vorname, nachname) VALUES ('Hello', 'World')" dim r as RecordSet = db.SQLSelect("SELECT @@IDENTITY") MsgBox r.IdxField(1).StringValue // Disconnect is optional // autodisconnect will ocur in destructor if needed MsgBox "OK" else MsgBox db.ErrorMessage end if End EventHandler
End Class
Class Window1 Inherits Window
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 tutorial videos