Contents Index Accessing data using dynamic SQL Data retrieval: SELECT

UltraLite for MobileVB User's Guide
  Understanding UltraLite for MobileVB Development
    Accessing data using dynamic SQL

Data manipulation: INSERT, UPDATE and DELETE


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 statements 
For 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:

  1. Declare a variable as ULPreparedStatement

    Dim PrepStmt As ULPreparedStatement
    Dim NewValue As String
    Dim RowCount As Long
  2. Assign a statement to the ULPreparedStatement object.

    Set PrepStmt = Connection. _
    PrepareStatement("INSERT MyTable(MyColumn) VALUES (?)")
  3. Assign input parameter values for the statement

    PrepStmt.SetStringParameter 1, NewValue
  4. Execute the statement

    RowCount = PrepStmt.ExecuteStatement

To perform UPDATE operations using ExecuteStatement:

  1. Declare variables needed for the operation:

    Dim PrepStmt As ULPreparedStatement
    Dim NewValue as String
    Dim RowCount As Long
    Dim ID As Integer
  2. Assign a prepared statement to your ULPreparedStatement object.

    Set PrepStmt = Connection.PrepareStatement( _
       "UPDATE customer SET name = ? WHERE ID = ?")
  3. Assign input parameter values for the statement, using a variable named ID you created.

    PrepStmt.SetStringParameter 1, NewValue
     PrepStmt.SetIntParameter 2, ID
  4. Execute the statement

    RowCount = PrepStmt.ExecuteStatement

To perform DELETE operations using ExecuteStatement:

  1. Declare a variable as ULPreparedStatement

    Dim PrepStmt As ULPreparedStatement
    Dim RowCount As Long
    Dim ID As Integer
  2. Assign a statement to the ULPreparedStatement object.

    Set PrepStmt = Connection.PrepareStatement( _
      "DELETE FROM customer WHERE ID = ?")
  3. Assign input parameter values to the statement

    PrepStmt.SetIntParameter 1, ID
  4. Execute the statement

    RowCount = PrepStmt.ExecuteStatement

Contents Index Accessing data using dynamic SQL Data retrieval: SELECT