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 Accessing Data in Code in 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 out (that is, the rows that are viewable)

Filter

Data that was filtered out

Delete

Data that was deleted by the user or in a script


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 the current filter criteria.

InsertRow

Inserts a new row.

Print

Sends the contents of the DataStore to the current printer.

Reset

Clears all rows in the DataStore.

Retrieve

Retrieves rows from the database.

RowsCopy

Copies rows from one DataStore to another DataStore or DataWindow control.

RowsMove

Moves rows from one DataStore to another DataStore or DataWindow control.

ShareData

Shares data among different DataStores or DataWindow controls. See Sharing information.

Sort

Sorts the rows of the DataStore based on the current sort criteria.

Update

Sends to the database all inserts, changes, and deletions that have been made since the last Update.


For information about DataStore methods, see Methods for the DataWindow Control in 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 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 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 DataWindow Reference.