Class TableDataSource
Represents a datasource based on DataTable class.
Inheritance
Inherited Members
Namespace: FastReport.Data
Assembly: FastReport.OpenSource.dll
Syntax
public class TableDataSource : DataSourceBase, IFRSerializable, IParent
Examples
This example shows how to add a new table to the existing connection:
Report report1;
DataConnectionBase conn = report1.Dictionary.Connections.FindByName("Connection1");
TableDataSource table = new TableDataSource();
table.TableName = "Employees";
table.Name = "Table1";
conn.Tables.Add(table);
Constructors
TableDataSource()
Initializes a new instance of the TableDataSource class with default settings.
Declaration
public TableDataSource()
Properties
Connection
Gets or sets the parent DataConnectionBase object.
Declaration
public DataConnectionBase Connection { get; set; }
Property Value
| Type | Description |
|---|---|
| DataConnectionBase |
Parameters
Gets a collection of parameters used by "select" command.
Declaration
public CommandParameterCollection Parameters { get; set; }
Property Value
| Type | Description |
|---|---|
| CommandParameterCollection |
Remarks
You must set up this property if the SQL query that you've specified in the SelectCommand property contains parameters.
You can pass a value to the SQL parameter in two ways.
The right way is to define a report parameter. You can do this in the "Data" window. Once you have defined the parameter, you can use it to pass a value to the SQL parameter. To do this, set the SQL parameter's Expression property to the report parameter's name (so it will look like [myReportParam]). To pass a value to the report parameter from your application, use the SetParameterValue(String, Object) method.
The other way (unrecommended) is to find a datasource object and set its parameter from a code:
TableDataSource ds = report.GetDataSource("My DataSource Name") as TableDataSource;
ds.Parameters[0].Value = 10;
This way is not good because you hardcode the report object's name.
QbSchema
Gets or sets the query builder schema.
Declaration
public string QbSchema { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Remarks
This property is for internal use only.
SelectCommand
Gets or sets SQL "select" command.
Declaration
public string SelectCommand { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Remarks
If this command contains parameters, you should specify them in the Parameters property.
StoreData
Gets or sets a value that determines whether it is necessary to store table data in a report file.
Declaration
public bool StoreData { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Table
Gets or sets the underlying DataTable object.
Declaration
public DataTable Table { get; set; }
Property Value
| Type | Description |
|---|---|
| DataTable |
TableData
Gets or sets the table data.
Declaration
public string TableData { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Remarks
This property is for internal use only.
TableName
Gets or sets the table name.
Declaration
public string TableName { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
AddChild(Base)
Adds a child object to this object's childs.
Declaration
public override void AddChild(Base child)
Parameters
| Type | Name | Description |
|---|---|---|
| Base | child | Object to add. |
Overrides
CanContain(Base)
Gets a value indicating that this object can contain the specified child object.
Declaration
public override bool CanContain(Base child)
Parameters
| Type | Name | Description |
|---|---|---|
| Base | child | Child object. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if this object can contain the specified child object; otherwise, false. |
Overrides
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | disposing |
Overrides
GetChildObjects(ObjectCollection)
Gets a list of child objects.
Declaration
public override void GetChildObjects(ObjectCollection list)
Parameters
| Type | Name | Description |
|---|---|---|
| ObjectCollection | list | List to fill with values. |
Overrides
GetValue(Column)
Gets data stored in a specified column.
Declaration
protected override object GetValue(Column column)
Parameters
| Type | Name | Description |
|---|---|---|
| Column | column | The column. |
Returns
| Type | Description |
|---|---|
| System.Object | An object that contains the data. |
Overrides
InitializeComponent()
Initializes the object before running a report.
Declaration
public override void InitializeComponent()
Overrides
Remarks
This method is used by the report engine, do not call it directly.
InitSchema()
Initializes the datasource schema.
Declaration
public override void InitSchema()
Overrides
Remarks
This method is used to support the FastReport.Net infrastructure. Do not call it directly.
LoadData(ArrayList)
Loads the datasource with data.
Declaration
public override void LoadData(ArrayList rows)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.ArrayList | rows | Rows to fill with data. |
Overrides
Remarks
This method is used to support the FastReport.Net infrastructure. Do not call it directly.
RefreshTable()
Refresh the table schema.
Declaration
public void RefreshTable()
RemoveChild(Base)
Removes a specified object from this object's childs.
Declaration
public override void RemoveChild(Base child)
Parameters
| Type | Name | Description |
|---|---|---|
| Base | child |
Overrides
Serialize(FRWriter)
Serializes the object.
Declaration
public override void Serialize(FRWriter writer)
Parameters
| Type | Name | Description |
|---|---|---|
| FRWriter | writer | Writer object. |
Overrides
Remarks
Do not call this method directly. You should override it if you are developing a new component for FastReport.
This method is called when the object needs to save the state. It may happen when:
- saving the report to the file or stream;
- saving the report to the designer's undo buffer;
- assigning the object to another object using the Assign(Base) or AssignAll(Base) methods;
- saving the object to the designer's clipboard;
- saving the object to the preview (when run a report).
SetParent(Base)
Sets the object's parent.
Declaration
public override void SetParent(Base value)
Parameters
| Type | Name | Description |
|---|---|---|
| Base | value | New parent. |
Overrides
Remarks
This method is for internal use only. You can use it if you are developing a new component for FastReport. Override it to perform some actions when the parent of an object is changing. This method checks that parent can contain a child.
Exceptions
| Type | Condition |
|---|---|
| ParentException | Parent object cannot contain this object. |