Data Table <dbDataTable>

Synopsis

DbDataTable is an Intent Design for reading from a data source, making in-memory changes to data, with an eventual bulk update of the data source from the memory data. DbDataTable design implements the disconnected mode of ADO.Net. dbDataTable is able to: Initially Fill() the memory table with the results of a SELECT statement Access the metadata through the ColumnNames Rule Determine the row count through the RowCount Rule Access the data through the GetFieldValue() or GetRowFieldValues() Methods Add new rows into the memory table through the AddRow() Method Delete rows from the memory table through the DeleteRow() Method Change data values in the rows through the SetFieldValue() or SetRowFieldValues() Methods Bulk update of the data source through the Update() Method

ADO.Net Designs assume that the dbDataTable parts should be children of dbConnection.

Parameters

Name Type Description
connection part Connection part, usually a Parent.
TableName string Required: Desired Name of the memory Data table.
SelectCommandText string Required: SQL statement.

Rules

Name Type Description
RowCount integer Number of records in the data table
ColumnNames list List of the column names.

Methods

Fill( ) As Any
Connects to the data source, and fills the memory table with the data
GetFieldValue( Row as Integer, Column as Any ) As Any
Returns the value at a specified zero-based row number and column. Column is a String or zero-based column number
GetRowFieldValues( Row As Integer ) As List
Returns the List of values at a specified zero-based row
AddRow( fieldValues As List, _
        Optional update? As Boolean = False ) As Any
Adds a new row into data table. The values are read from the List . The value order should correspond to the column names of the data table. If the change should be immediately propagated to the data source, call the method with update? := True
SetFieldValue( Row As Integer, _
               Column as Any, _
               Value As Any, _
               Optional update? As Boolean = False ) As Any
Sets a new value to the field. Row is a zero-based Integer; Column is either a zero-based integer, or the column name String . If the change should be immediately propagated to the data source, call the method with update?:= True
SetRowFieldValues( Row As Integer, _
                   Values As List, _
                   Optional update? As Boolean = False ) As Any
Sets the existing row with the new Values. Row is a zero-based Integer . The order of the Values should correspond to the order of the column names in the data table. If the change should be immediately propagated to the data source, call the method with update?:= True
DeleteRow( Row As Integer, _
           Optional update? As Boolean = False ) As Any
Deletes the Row (zero-based) from the data table. If the change should be immediately propagated to the data source, call the method with update?:= True
Update( Optional refresh? As Boolean = True ) As Any
Propagates all the changes on the data table to the data source. The content of the data table is optionally refreshed.

Changes to the database

In this case, the result is returned in a result set.

Child Name: spRun
Child Design: DbQueryCommand
Name Type Supplied
connection part Root.sqlServerConnection
tableName string MemoryTable
SelectCommandText string SELECT * From CarsTable
Intent >AddRow({100,"Tatra","White","Czech"}) ?Add new car
--> True
Intent >DeleteRow(1) ?Delete ?Lada? car
--> True
Intent >SetFieldValue(4,"Comments","Italian") ?Change Italia->Italian
--> True
Intent >Update() ?Bulk update
--> True