Active Query Builder for .NET 3.0

- Standard way of getting SQL query text

Using the QueryBuilder visual control, you can setup SQL text formatting using the QueryBuilder.SQLFormattingOptions property group and read SQL text from the QueryBuilder.FormattedSQL property.

- Alternate way of getting SQL query text

The SQLBuilder or FormattedSQLBuilder objects must be used when you need to get SQL query text. The GetSQL static method of these objects accepts SubQuery and SQLGenerationOptions/SQLFormattingOptions objects, and returns SQL text in result. The SQLFormattingOptions class is inherited from the SQLGenerationOptions class. Both are used to store SQL generation options, such as the need for quotation all identifiers in query text, the need for fully qualified notation of database object and field names, etc. The SQLFormattingOptions object additionaly holds properties to tune formatting of SQL query text (line breaks, indents, word wrapping).

sqlTextEditor1.Text = FormattedSQLBuilder.GetSQL(sqlQuery1.QueryRoot, sqlFormattingOptions1);


Other editions

In version 2.x and lower, to get the formatted SQL text, you should create an instance of the PlainTextSQLBuilder object and assign a QueryBuilder object to the PlainTextSQLBuilder.QueryBuilder property. After that you can handle the PlainTextSQLBuilder.SQLUpdated event to get the formatted SQL text.

The links below point to the lists of available properties of AQB.NET 2.0 to setup the formatting:

PlainTextSQLBuilder inherits BaseSQLBuilder which has separate sets of properties for Main query, expression sub-queries, derived tables and Common Table Expressions.

A set of formatting options for a single query is reprtesented by the SQLBuilderSelectFormat class.

Is this article helpful for you?