Accessing and manipulating data in a DataStore
To access data using a DataStore, you need to read the data
from the data source into the DataStore.
If the data source is a database
If the data for the DataStore is coming from a database (that
is, the data source was defined as anything but External in the
DataWindow painter), you need to communicate with the database to
get the data. The steps you perform to communicate with the database
are the same steps you use for a DataWindow control.
For more information about communicating with
the database, see “Accessing the database”.
If the data source is not a database
If the data for the DataWindow object is not coming from a
database (that is, the data source was defined as External in the
DataWindow painter), you can use the following methods to import
data into the DataStore:
-
ImportClipboard
-
ImportFile
-
ImportString
You can also get data into the DataStore by using a DataWindow
data expression, or by using the SetItem method.
For more information on accessing data in
a DataStore, see the DataWindow Reference.
About the DataStore buffers
Like a DataWindow control, a DataStore uses three buffers
to manage data:
Buffer |
Contents |
---|---|
Primary |
Data that has not been deleted or filtered |
Filter |
Data that was filtered out |
Delete |
Data that was deleted by the user or |
About the Edit control
The DataStore object has an Edit control. However, the Edit
control for a DataStore behaves in a slightly different manner from
the Edit control for a DataWindow. The Edit control for a DataWindow
keeps track of text entered by the user in the current cell (row
and column); the Edit control for a DataStore is used to manage
data imported from an external source, such as the clipboard or
a file. The text in the Edit control for a DataStore cannot be changed
directly by the user. It must be manipulated programmatically.
Programming with DataStores
There are many methods for manipulating DataStore objects.
These are some of the more commonly used:
Method |
Purpose |
---|---|
DeleteRow |
Deletes the specified row from the DataStore. |
Filter |
Filters rows in the DataStore based on |
InsertRow |
Inserts a new row. |
|
Sends the contents of the DataStore to |
Reset |
Clears all rows in the DataStore. |
Retrieve |
Retrieves rows from the database. |
RowsCopy |
Copies rows from one DataStore to another |
RowsMove |
Moves rows from one DataStore to another |
ShareData |
Shares data among different DataStores |
Sort |
Sorts the rows of the DataStore based |
Update |
Sends to the database all inserts, changes, |
For information about DataStore methods, see
the DataWindow Reference.
Dynamic DataWindow objects
The methods in the table above manipulate data in the DataStore
but do not change the definition of the underlying DataWindow object.
In addition, you can use the Modify and Describe methods to access
and manipulate the definition of a DataWindow object. Using
these methods, you can change the DataWindow object during execution.
For example, you can change the appearance of a DataWindow or allow
your user to create ad hoc reports.
For more information, see Chapter 3, “Dynamically Changing DataWindow
Objects .”
Property and data expressions
You can use the same property and data expressions as for
the DataWindow control. For information, see the DataWindow
Reference.
Using DataStore properties and events
This chapter mentions only a few of the properties and events
that you can use to manipulate DataStores. For more information
about DataStore properties and events, see the DataWindow Reference.