Example: /SQL/SQLDatabaseMBS MSSQL Execute

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/SQL/SQLDatabaseMBS MSSQL Execute


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.xojo_binary_project"
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:

The items on this page are in the following plugins: MBS SQL Plugin.


💬 Ask a question or report a problem