DhDataSource Class

DhDataSource Class

This Package | All Packages

public class DhDataSource

Represents a generic wrapper class for data sources. It allows access to any object that is a data source, regardless of the tag type. This class also encapsulates access to the Data Source object ADO recordset functions.

Constructors
Name Description
DhDataSource( DhElement e ) Creates a DhDataSource object.

Methods
Name Description
addNew() Creates a new record for the recordset.
addOnDataAvailable( DhEventHandler h ) Adds an event handler for the DataAvailable event.
addOnDataSetChanged( DhEventHandler h ) Adds an event handler for the DataSetChanged event.
addOnDataSetComplete( DhEventHandler h ) Adds an event handler for the DataSetComplete event.
cancelUpdate() Cancels the current update operation, and restores recordset to its prior state.
delete() Deletes the current record from the recordset.
getAbsolutePosition( ) Retrieves the ordinal position of the current record in the recordset.
getBOF() Determines if the current record is before the first record.
getDataFieldIndex( String strFieldName ) Returns the ordinal column number of the column specified.
getDataFieldName( int nField ) Returns the string name of the recordset field at the specified ordinal position.
getEditMode() Retrieves the current edit mode.
getEOF() Determines if the current record is after the last record.
getFieldUpdatable( int nField ) Determines if the specified field is writeable.
getFieldUpdatable( String strField ) Determines if the specified field is writeable.
getID() Retrieves the identifier for the element associated with this data source.
getRecordCount() Returns the number of records in the recordset.
getRecordsetPeer() Returns the ADO recordset object represented by the data source object.
move( int nRecords ) Moves the recordset a specified number of records.
moveFirst() Moves to the first record in the recordset.
moveLast() Moves to the last record in the recordset.
moveNext() Moves to the next record in the recordset.
movePrevious() Moves to the previous record in the recordset.
refresh() Refreshes the recordset by reissuing the query that created it.
setAbsolutePosition( int nPos ) Sets the internal recordset to an ordinal record position.
setDataSourceFromElement( DhElement e ) Sets the element this DhDataSource represents.
update() Commits an in-progress edit operation.

Constructors

DhDataSource.DhDataSource

Syntax
protected DhDataSource( DhElement e );
Parameters
e
The data source element to be contained.
Description

Creates a DhDataSource object. This constructor wraps an existing element that is a data source.

Methods

DhDataSource.addNew

Syntax
public synchronized boolean addNew();
Return Value

Returns true if successful; otherwise, returns false.

Description

Creates a new record for the recordset. The record will not be added until update() is called.

See Also
update

DhDataSource.addOnDataAvailable

Syntax
public synchronized void addOnDataAvailable( DhEventHandler h );
Parameters
h
The event handler.
Description

Adds an event handler for the DataAvailable event.

DhDataSource.addOnDataSetChanged

Syntax
public synchronized void addOnDataSetChanged( DhEventHandler h );
Parameters
h
The event handler.
Description

Adds an event handler for the DataSetChanged event.

DhDataSource.addOnDataSetComplete

Syntax
public synchronized void addOnDataSetComplete( DhEventHandler h );
Parameters
h
The event handler.
Description

Adds an event handler for the DataSetComplete event.

DhDataSource.cancelUpdate

Syntax
public synchronized boolean cancelUpdate();
Return Value

Returns true if successful; otherwise, returns false.

Description

Cancels the current update operation, and restores recordset to its prior state.

See Also
update

DhDataSource.delete

Syntax
public synchronized boolean delete();
Return Value

Returns true successful; otherwise, returns false.

Description

Deletes the current record from the recordset.

See Also
update

DhDataSource.getAbsolutePosition

Syntax
public synchronized int getAbsolutePosition( );
Return Value

Returns the zero-based position of the record, or returns -1 if the ordinal position cannot be determined.

Description

Retrieves the ordinal position of the current record in the recordset.

DhDataSource.getBOF

Syntax
public synchronized boolean getBOF();
Return Value

Returns true if at the first record; otherwise, returns false.

Description

Determines if the current record is before the first record.

DhDataSource.getDataFieldIndex

Syntax
public synchronized int getDataFieldIndex( String strFieldName );
Parameters
strFieldName
The name of the column to retrieve position.
Return Value

Returns the zero-based ordinal position of column in recordset.

Description

Returns the ordinal column number of the column specified.

DhDataSource.getDataFieldName

Syntax
public synchronized String getDataFieldName( int nField );
Parameters
nField
The zero-based position of the field to retrieve name of.
Return Value

Returns the name of the field, or returns a null string if it is unavailable.

Description

Returns the string name of the recordset field at the specified ordinal position.

DhDataSource.getEditMode

Syntax
public synchronized int getEditMode();
Return Value

Returns the current edit mode, which can be one of the following:

Description

Retrieves the current edit mode.

DhDataSource.getEOF

Syntax
public synchronized boolean getEOF();
Return Value

Returns true if at the last record; otherwise, returns false.

Description

Determines if the current record is after the last record.

DhDataSource.getFieldUpdatable

Syntax 1
public synchronized boolean getFieldUpdatable( int nField );
Parameters
nField
The ordinal position of the field to check permissions.
Return Value

Returns true if a write operation is allowed, returns false if not.

Description

Determines if the specified field is writeable.



Syntax 2
public synchronized boolean getFieldUpdatable( String strField );
Parameters
nField
The string name of the field to check permissions.
Return Value

Returns true if a write operation is allowed, returns false if not.

Description

Determines if the specified field is writeable.

DhDataSource.getID

Syntax
public String getID();
Return Value

Returns the identifier of the associated element.

Description

Retrieves the identifier for the element associated with this data source.

DhDataSource.getRecordCount

Syntax
public synchronized int getRecordCount();
Return Value

Returns 0 or greater if successful; otherwise, returns -1.

Description

Returns the number of records in the recordset. This number is often an estimate, and relies on the underlying recordset.

DhDataSource.getRecordsetPeer

Syntax
public synchronized Recordset getRecordsetPeer();
Return Value

Returns an ADO recordset object, or returns null if that interface cannot be obtained.

Description

Returns the ADO recordset object represented by the data source object. Not all data source objects expose a recordset object (for example, the Tabular Data Control does not).

DhDataSource.move

Syntax
public synchronized boolean move( int nRecords );
Parameters
nRecords
Number of records to move forward or backwards if negative If greater than zero, the current record position moves forward (toward the end of the recordset). If less than zero, the current record position moves backward (toward the beginning of the recordset).
Return Value

Returns true successful; otherwise, returns false.

Description

Moves the recordset a specified number of records.

DhDataSource.moveFirst

Syntax
public synchronized boolean moveFirst();
Return Value

Returns true if successful; otherwise, returns false.

Description

Moves to the first record in the recordset.

DhDataSource.moveLast

Syntax
public synchronized boolean moveLast();
Return Value

Returns true successful; otherwise, returns false.

Description

Moves to the last record in the recordset.

DhDataSource.moveNext

Syntax
public synchronized boolean moveNext();
Return Value

Returns true if successful; otherwise, returns false.

Description

Moves to the next record in the recordset.

DhDataSource.movePrevious

Syntax
public synchronized boolean movePrevious();
Return Value

Returns true if successful; otherwise, returns false.

Description

Moves to the previous record in the recordset.

DhDataSource.refresh

Syntax
public synchronized boolean refresh();
Return Value

Returns true successful; otherwise, returns false.

Description

Refreshes the recordset by reissuing the query that created it.

DhDataSource.setAbsolutePosition

Syntax
public synchronized boolean setAbsolutePosition( int nPos );
Parameters
nPos
The ordinal (zero-based) position of the record to move to.
Return Value

Returns true if successful; otherwise, returns false.

Description

Sets the internal recordset to an ordinal record position.

DhDataSource.setDataSourceFromElement

Syntax
public synchronized void setDataSourceFromElement( DhElement e );
Parameters
e
The data source object element to encapsulate. Recordset operations will be available only if e is a DhObjectFactory object or a class derived from DhObjectFactory.
Description

Sets the element this DhDataSource represents.

DhDataSource.update

Syntax
public synchronized boolean update();
Return Value

Returns true if the update was successful; otherwise, returns false.

Description

Commits an in-progress edit operation.

See Also
addNew