ComponentOne DataObjects for .NET
BeforeGenerateSql Event (C1DataSetLogic)

C1.Data.2 Assembly > C1.Data Namespace > C1DataSetLogic Class : BeforeGenerateSql Event
Fired before generating the SQL SELECT statement for fetching a table view from the database.
Syntax
'Declaration
 
Public Event BeforeGenerateSql As GenerateSqlEventHandler
public event GenerateSqlEventHandler BeforeGenerateSql
Event Data

The event handler receives an argument of type GenerateSqlEventArgs containing data related to this event. The following GenerateSqlEventArgs properties provide information specific to this event.

PropertyDescription
ClauseSelect/ClauseFrom/ClauseWhere/ClauseOrderBy are read-only properties that are available in AfterGenerateSql event (not available in BeforeGenerateSql). They contain corresponding parts of the automatically generated SQL SELECT statement (the complete statement is available in the Sql property). They can be used to modify/compose a statement, for example, to add TOP n or another clause after the SELECT clause.  
ClauseSelect/ClauseFrom/ClauseWhere/ClauseOrderBy are read-only properties that are available in AfterGenerateSql event (not available in BeforeGenerateSql). They contain corresponding parts of the automatically generated SQL SELECT statement (the complete statement is available in the Sql property). They can be used to modify/compose a statement, for example, to add TOP n or another clause after the SELECT clause.  
ClauseSelect/ClauseFrom/ClauseWhere/ClauseOrderBy are read-only properties that are available in AfterGenerateSql event (not available in BeforeGenerateSql). They contain corresponding parts of the automatically generated SQL SELECT statement (the complete statement is available in the Sql property). They can be used to modify/compose a statement, for example, to add TOP n or another clause after the SELECT clause.  
ClauseSelect/ClauseFrom/ClauseWhere/ClauseOrderBy are read-only properties that are available in AfterGenerateSql event (not available in BeforeGenerateSql). They contain corresponding parts of the automatically generated SQL SELECT statement (the complete statement is available in the Sql property). They can be used to modify/compose a statement, for example, to add TOP n or another clause after the SELECT clause.  
The IDbCommand object containing the generated SQL SELECT statement.  
Filter conditions used to fill the data set. These are all filter conditions for all table views in the data set. You need to extract the filter conditions for the particular table view from this argument.  
SQL statement. The programmer can set this argument in the event code to set or modify the SQL SELECT statement used for fetching data. Alternatively, the programmer can set or modify the Command argument to specify the complete command to be executed.  
Success or failure status of the operation. In events occurring before operation and allowing to change the status argument, user code can change the status to indicate whether to proceed with the operation, skip or abort it.  
The table view populated with the SQL SELECT statement.  
Remarks
This event is used for SQL-based tables to specify the SQL SELECT statement that populates the table, fetches data from the database. The SQL statement is assigned to the Sql argument or to the CommandText property of the Command argument.

If you use the Command argument, the command does not necessarily have to contain a SELECT statement. You can use a stored procedure instead, or you can use a parameterized SELECT. You can even create your own command object and assign it to the Command argument. The only requirement is that you set up the Command argument passed to the event with all necessary properties so it becomes a valid IDbCommand ready for execution. C1DataObjects executes the command's ExecuteReader method.

See Also

Reference

C1DataSetLogic Class
C1DataSetLogic Members
Bound, SQL-Based and Unbound Tables