UltraLite ActiveX User's Guide
Understanding UltraLite ActiveX Development
Accessing and manipulating data using Dynamic SQL
With UltraLite, you can perform INSERT, UPDATE and DELETE operations. These operations are performed using the ExecuteStatement method, a member of the ULPreparedStatement class.
For more information the ULPreparedStatement class, see ULPreparedStatement class.
UltraLite handles variable values using the ? character.
Using (?) in your prepared statementsFor any INSERT, UPDATE or DELETE, each (?) is referenced according to its ordinal position in the prepared statement. For example, the first (?) is referred to as 1, and the second as 2. |
To INSERT a row
Declare a ULPreparedStatement object.
' eMbedded Visual Basic Dim PS As ULPreparedStatement
// JScript var PS;
Assign an INSERT statement to your prepared statement object. In the following code fragment, TableName and ColumnName are the names of a table and column.
' eMbedded Visual Basic Set PS = Connection.PrepareStatement("INSERT into TableName(ColumnName) values (?)")
// JScript PS = Connection.PrepareStatement("INSERT into TableName(ColumnName) values (?)");
Assign values for (?) to the statement.
' eMbedded Visual Basic Dim NewValue as String NewValue = "Bob" PS.SetStringParameter 1, NewValue
// JScript var NewValue; NewValue = "Bob"; PS.SetStringParameter(1, NewValue);
Execute the statement.
' eMbedded Visual Basic PS.ExecuteStatement
// JScript PS.ExecuteStatement();
To UPDATE a row
Declare a ULPreparedStatement object.
' eMbedded Visual Basic Dim PS As ULPreparedStatement
// JScript var PS;
Assign an UPDATE statement to your prepared statement object. In the following code fragment, TableName and ColumnName are the names of a table and column.
' eMbedded Visual Basic Set PS = Connection.PrepareStatement("UPDATE TableName SET ColumnName = (?) WHERE ID = (?)")
// JScript PS = Connection.PrepareStatement("UPDATE TableName SET ColumnName = (?) WHERE ID = (?)");
Assign values for (?) to the statement.
' eMbedded Visual Basic Dim NewValue as String NewValue = "Bob" PS.SetParameter 1, NewValue PS.SetParameter 2, "6"
// JScript var NewValue; NewValue = "Bob"; PS.SetParameter(1, NewValue); PS.SetParameter(2, "6");
Execute the statement
' eMbedded Visual Basic PS.ExecuteStatement
// JScript PS.ExecuteStatement();
To DELETE a row
Declare a ULPreparedStatement object.
' eMbedded Visual Basic Dim PS As ULPreparedStatement
// JScript var PS;
Assign a DELETE statement to your prepared statement object.
' eMbedded Visual Basic Set PS = Connection.PrepareStatement("DELETE FROM customer WHERE ID = (?)")
// JScript PS = Connection.PrepareStatement("DELETE FROM customer WHERE ID = (?)");
Assign values for (?) to the statement.
' eMbedded Visual Basic Dim IDValue as String IDValue = "6" PS.SetParameter 1, IDValue
// JScript var IDValue; IDValue = "6"; PS.SetParameter( 1, IDValue );
Execute the statement.
'eMbedded Visual Basic PS.ExecuteStatement
// JScript PS.ExecuteStatement();