Getting unformatted SQL Text
Active Query Builder is a component intended to build SQL queries as well as to parse them and represent them visually. Thus, the main property is the QueryBuilder.SQL property. You can read it to get unformatted SQL query text for executing against a database server, and you can write to it to parse a query and represent it visually.
Getting formatted SQL Text
- ActiveX Edition
- .NET 2.x and 1.x, Java and VCL Editions
- Active Query Builder for .NET 3
sqlTextEditor1.Text = FormattedSQLBuilder.GetSQL(sqlQuery1.QueryRoot, new SQLFormattingOptions());
Saving and Loading SQL query text between work sessions
- with layout of objects within the Design Pane
The QueryBuilder.LayoutSQL property allows to save and to load the layout of objects within the Design Pane among with the query text, so the component's visual state could be saved between work sessions.
- with text formatting
To save the text formatting in the SQL text editor you should read and write the SqlTextEditor.Text property.
- combining these techniques
Both properties should be used to save both SQL text formatting and query visual layout between work sessions. The sequence of reading them to save a query is not important, but you should write the QueryBuilder.LayoutSQL property first and then write the formatted SQL query text to both the QueryBuilder.SQL and the SqlTextEditor.Text properties.
Getting the query text and layout with the ASP.NET you should use the following code:
// if QueryBuilderControl.MultipleQueriesPerSession = false (default) SessionStoreItem item = SessionStore.Current; // if QueryBuilderControl.MultipleQueriesPerSession = true SessionStoreItem item = SessionStore.GetCurrent("SessionId"); string sql = item.ClientSQL; string layout = item.Layout;
Syncronizing Active Query Builder with the SQL Text Editor
Use the QueryBuilder.SQLUpdated event to get new SQL query text each time when the query is updated in Active Query Builder visually or programmatically. To disable the firing of this event during batch programmatic changes, use the BeginUpdate and EndUpdate methods.
Customer support service by UserEcho