DataTable
From Pointui
Provides access to a table of data. This is used to access Appointments, Contacts, Tasks, Messages, and other data.
For more information also see Using DataTable Objects.
Methods
bool MoveNext()
Moves to the next row in the table. IMPORTANT NOTE: GetValue() cannot be used to fetch values for the first row until MoveNext() has been called once – see the example below.
RETURN VALUE
Returns true if the next row existed and was successfully moved to. A return value of true means that GetValue() can now be used to retrieve values for the row. If there are no more rows left then false is returned.
COMPATIBILITY
Supported in all data tables.
EXAMPLE
DataTable appts; //fetch all appointments Appointments.GetAppointments(appts); //go through all appointments //notice that MoveNext is called before accessing values from the first row while (appts.MoveNext()) { //do something with this appointment //read out the start date/time DateTime dt; appts.GetValue(“StartDate”, dt); }
bool MoveTo(int index)
Moves to a specific row in the table.
RETURN VALUE
Returns true if the next row existed and was successfully moved to. A return value of true means that GetValue() can now be used to retrieve values for the row. If there are no more rows left then false is returned.
COMPATIBILITY
Only supported in data tables returned from:
void GetValue(String columnName, String result)
void GetValue(String columnName, int result)
void GetValue(String columnName, DateTime result)
Gets the value of the column specified and copies it’s value into the result parameter provided. This allows column values to be retrieved for the current row.
PARAMETERS
- columnName – the case sensitive column name of the column whose value is to be returned.
- result – the variable which is used to return the column value into. The type of the variable supplied must match the data type of the value being requested.
COMPATIBILITY
Supported in all data tables.
EXAMPLE
DataTable appts; Appointments.GetAppointments(appts); while (appts.MoveNext()) { //read out the start date/time DateTime dt; appts.GetValue(“StartDate”, dt); //read the subject of the appointment String s; appts.GetValue(“Subject”, s); }
void SetColumns(String columns)
Sets the columns that are to be returned in the table. Only the columns specified can be accessed with GetValue() for data tables that require columns to be specified – see Compatibility below.
PARAMETERS
- columns – contains a comma separated list of column names to include in the table when it is prepared.
COMPATIBILITY
Only supported in data tables returned from:
void SetSort(String columnName, String sortDirection)
Sets the column name to be used for sorting and the direction.
PARAMETERS
- columnName – name of the column to use for sorting the rows.
- sortDirection (optional) – must be one of the following String values:
- “Ascending” (default)
- “Descending”
COMPATIBILITY
Only supported in data tables returned from:
void SetRestriction(String query)
Limits the table to only contain rows matching the query supplied in the restriction parameter.
PARAMETERS
- query – query to be applied to the table to limit the rows returned. The format of the query can be different depending on the type of data in the table.
The data for the following:
is fetched from POOM, and the query provided is passed directly to POOM for processing so must be consistent with the capabilities Microsoft have provided and documented in POOM. A few things to note:
- Square brackets are used to enclose the column names (e.g. “[Start]”)
- Date/times must be in the Variant format, see DateTime.ToVariantTime()
- Date/times require a strange markup – they must start with a “<” symbol (e.g. “[Start] > <35000.0
EXAMPLE
//get appointments DataTable tbl; Appointments.GetAppointments(tbl); //don’t return any more than 4 items tbl.SetMaxItems(4); //sort ascending by start time tbl.SetSort("Start"); //build a query string that will be used to filter the appointments String filter; filter = "[End] >= <{Now} AND [Start] < <{End}"; //get current datetime DateTime dt; dt.Now(); //convert the current time to a floating point variant time as required by POOM String tmp; float f; f = dt.ToVariantTime(); tmp = f.ToString("%.5f"); filter = filter.Replace("{Now}", tmp); //get the start of the next day dt.AddDays(1); f = dt.ToVariantTime(); f.Trunc(); tmp = f.ToString("%.0f"); filter = filter.Replace("{End}", tmp); //apply the restriction tbl.SetRestriction(filter); //do something with the appointments while (tbl.MoveNext()) { //… }
void SetMaxItems(int maxItems)
Sets the maximum number of items to be returned in the table even if more are available.
PARAMETERS
- maxItems – maximum number of items to be returned.
COMPATIBILITY
Supported in all data tables.
int GetCount()
Returns the number of rows in the table.
COMPATIBILITY
Only supported in data tables returned from:
