UltraLite for MobileVB User's Guide
Understanding UltraLite for MobileVB Development
Accessing data using dynamic SQL
UltraLite can perform numerous common SQL Data Manipulation Language operations using the ExecuteStatement method, a member of the ULPreparedStatement class. With UltraLite, you can perform INSERT, UPDATE and DELETE operations just as you can with any SQL database.
UltraLite handles variable values using the ? character.
Using input parameters (?) in your prepared statementsFor any INSERT, UPDATE or DELETE, each ? is referred to by its ordinal position in the prepared statement. The first ? is referred to as 1, the second 2, and so on. |
To perform INSERT operations using ExecuteStatement:
Declare a variable as ULPreparedStatement
Dim PrepStmt As ULPreparedStatement Dim NewValue As String Dim RowCount As Long
Assign a statement to the ULPreparedStatement object.
Set PrepStmt = Connection. _ PrepareStatement("INSERT MyTable(MyColumn) VALUES (?)")
Assign input parameter values for the statement
PrepStmt.SetStringParameter 1, NewValue
Execute the statement
RowCount = PrepStmt.ExecuteStatement
To perform UPDATE operations using ExecuteStatement:
Declare variables needed for the operation:
Dim PrepStmt As ULPreparedStatement Dim NewValue as String Dim RowCount As Long Dim ID As Integer
Assign a prepared statement to your ULPreparedStatement object.
Set PrepStmt = Connection.PrepareStatement( _ "UPDATE customer SET name = ? WHERE ID = ?")
Assign input parameter values for the statement, using a variable named ID you created.
PrepStmt.SetStringParameter 1, NewValue PrepStmt.SetIntParameter 2, ID
Execute the statement
RowCount = PrepStmt.ExecuteStatement
To perform DELETE operations using ExecuteStatement:
Declare a variable as ULPreparedStatement
Dim PrepStmt As ULPreparedStatement Dim RowCount As Long Dim ID As Integer
Assign a statement to the ULPreparedStatement object.
Set PrepStmt = Connection.PrepareStatement( _ "DELETE FROM customer WHERE ID = ?")
Assign input parameter values to the statement
PrepStmt.SetIntParameter 1, ID
Execute the statement
RowCount = PrepStmt.ExecuteStatement