Database.SQLExecute

From Xojo Documentation

Method

Database.SQLExecute(ExecuteString as String)

Supported for all project types and targets.

Used to execute an SQL command. Use this for commands that do not return any data, such as CREATE TABLE or INSERT. ExecuteString contains the SQL statement.

Notes

To avoid SQL Injection, be sure to use Prepared SQL Statements or Database.ExecuteSQL.

Sample Code

This code creates the Team table:

// App.DB is a SQLite database
Dim sql As String
sql = "CREATE TABLE Team (ID INTEGER NOT NULL, Name TEXT, Coach TEXT, City TEXT, PRIMARY KEY(ID));"

App.DB.SQLExecute(sql)

If App.DB.Error Then
MsgBox("DB Error: " + App.DB.ErrorMessage)
Else
MsgBox("Team table created successfully.")
End If