UltraLite ActiveX User's Guide
Understanding UltraLite ActiveX Development
Accessing and manipulating data using the table API
The following code opens the customer table and scrolls through its rows. It then displays a message box with last name of each customer.
' eMbedded Visual Basic Dim tCustomer as ULTable Set tCustomer = Connection.GetTable( "customer" ) tCustomer.Open ' the third column contains the last name of the customer Set colLastName = tCustomer.Columns.Item(3) tCustomer.MoveBeforeFirst While tCustomer.MoveNext MsgBox colLastName.Value Wend
// JScript var tCustomer; tCustomer = Connection.GetTable( "customer" ); tCustomer.Open(); // the third column contains the last name of the customer colLastName = tCustomer.Columns.Item(3); tCustomer.MoveBeforeFirst(); While (tCustomer.MoveNext()) { alert( colLastNmae.Value ); }
The columns of a table are contained in a Columns collection. You can address columns by index number (the order in which they were created in the schema file) or by name. For example, the following code accesses the LastName column:
' eMbedded Visual Basic Set colLastName = tCustomer.Columns.(LastName)
// JScript colLastName = tCustomer.Columns.(LastName);
You expose the rows of the table to the application when you open the table object. By default, the rows are exposed in order by primary key value, but you can specify an index to access the rows in a particular order. The following code moves to the first row of the customer table as ordered by the ix_name index.
' eMbedded Visual Basic Set tCustomer = Connection.GetTable("customer") tCustomer.Open "ix_name" tCustomer.MoveFirst
// JScript tCustomer = Connection.GetTable("customer"); tCustomer.Open("ix_name"); tCustomer.MoveFirst();