ComponentOne DataObjects for .NET
Bound, SQL-Based, and Unbound Tables
DataObjects for .NET (Enterprise Edition) > Schema Objects > Simple Tables > Bound, SQL-Based, and Unbound Tables

The most common case is a bound table (DataMode = Bound) where a table has non-empty Connection and DbTableName properties. In this case, a table is based on a database table, so all database access operations can be performed by DataObjects for .NET automatically. There is no need to write custom code fetching and updating the table data (although it is possible to customize the default behavior in code).

In more complicated cases, there may be a need for more flexibility. For example, you may need to use a complex, non-standard SQL statement to fetch table data, or to use a stored procedure. Normally, for a bound table, the SQL statements fetching and updating data are generated by DataObjects for .NET. If that is not adequate, you can use a SQL-based table (DataMode = SqlBased). A SQL-based table has non-empty Connection property and empty DbTableName property. Instead of DbTableName it uses the SelectCommandText property where you can specify a SQL statement or a stored procedure depending on the SelectCommandType property setting.

To define a SQL-based table, set the DataMode property to SqlBased, set the Connection property, leave the DbTableName property empty, and specify the SelectCommandType and SelectCommandText properties.

Using a SQL-based table can be almost as easy as using a bound table, if you create a DataAdapter component for it. A DataAdapter component can be created in a C1TableLogic component associated with the table by selecting Create DataAdapter from its context menu. The DataAdapter component will then perform both fetch and update without custom code (but you can customize the default fetch and update behavior in event code if needed).

Note: For an example of using a SQL-based table with DataAdapter, see the SQLBasedTablesEasy sample which is installed with the Studio for WinForms samples.

Although SQL-based tables are almost as easy to use as bound tables, bound tables are always preferable when you have a choice. Bound tables are more intimately related to database tables, so DataObjects for .NET can support features that are impossible for SQL-based tables; for example:

If you want even more control over fetch and update process, you can use a SQL-based table without DataAdapter component and even without setting the SelectCommandText property. In this case you perform fetch and update by generating SQL statement(s) in code:

Note: For an example of using SQL-based tables without DataAdapter, see the SQLBasedTables sample which is installed with the Studio for WinForms samples.

You can also combine these options, using these custom SQL statements created in code with a SQL-based table with DataAdapter, or, for that matter, event with a bound table. For example, you can fetch data without custom code, using DbTableName or SelectCommandText properties, and update with custom code.

If you need even more flexibility than provided by SQL-based tables, for example, when working against a non-SQL data source, you can use an unbound table. An unbound table is a table with both DbTableName and Connection properties empty (set the DataMode property to Unbound). Fetching and updating data for an unbound table is done in code, for example:

Note: For an example of how to use unbound tables, see the UnboundTables sample, which is installed with the Studio for WinForms samples.