Skip to content

Commit 6691468

Browse files
author
epolevikov
committed
Upd
1 parent 0330375 commit 6691468

File tree

28 files changed

+196
-1
lines changed

28 files changed

+196
-1
lines changed

interface-elements-for-desktop/articles/report-designer/report-designer-for-winforms/report-designer-tools/query-builder.md

Lines changed: 196 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,202 @@
11
---
22
title: Query Builder
33
---
4-
# Query Builder
4+
5+
# SQL Query Builder (WinForms)
6+
7+
The **Query Builder** allows you to construct SQL queries to retrieve data from an [SQL Database](TODO).
8+
9+
![Query Builder](../../../../images/winforms-sql-query-builder.png)
10+
11+
## Run the Query Builder
12+
13+
Use the [Data Source Wizard](TODO) or [Report Wizard](TODO) to bind your report to an [SQL Database](TODO). Switch to the [query customization page](TODO) and click the *Add* button in the **Queries** row.
14+
15+
![Data Source Wizard's Query Customization Page](../../../../images/winforms-data-source-wizard-query-customization-page.png)
16+
17+
## Select Tables
18+
19+
Drag the table that you want to add to a query from the list of available tables and drop the table onto the **Query Builder** surface.
20+
21+
![Query Builder: Drag and Drop a Table](../../../../images/winforms-query-builder-drag-and-drop-table.png)
22+
23+
To find a table by name, switch to the table list, press *CTRL+F*, and enter the table name in the editor.
24+
25+
![Query Builder: Find a Table by Name](../../../../images/winforms-query-builder-find-table-by-name.png)
26+
27+
Enable checkboxes for the table columns that you want to include in the query.
28+
29+
![Query Builder: Select Columns](../../../../images/winforms-query-builder-select-columns.png)
30+
31+
If you want to include all the columns available in the table, enable **\* (All Columns)**.
32+
33+
Right-click the table and select *Rename* or *Delete* to change the table's name or remove it.
34+
35+
![Query Builder: Rename or Delete Column](../../../../images/winforms-query-builder-delete-or-rename-column.png)
36+
37+
## Join Tables
38+
39+
You can join multiple tables within the same query. Do one of the following to add a table onto the **Query Builder** surface:
40+
41+
- Drag and drop a table from the table list onto the surface.
42+
- Double-click a table in the table list.
43+
44+
The table list on the left highlights all child and parent tables that are bound to the dropped table by a foreign key.
45+
46+
![Query Builder: Table Added to a Query](../../../../images/winforms-query-builder-table-added-to-a-query.png)
47+
48+
Add required tables to the surface. The *Inner Join* relation with the previously added table is created automatically. Added tables display the green plus button for the columns that refer to other tables. You can click this icon to add a linked table to the query and create the *Inner Join* relation with this table.
49+
50+
![Query Builder: Create the Inner Join Relation Automatically](../../../../images/winforms-query-builder-create-inner-join-relation-automatically.png)
51+
52+
Right-click a relation to edit, delete, or reverse.
53+
54+
![Query Builder: Edit Relation](../../../../images/winforms-query-builder-edit-relation.png)
55+
56+
The *Edit Relation* command invokes the **Join Editor**. It allows you to specify the join type (*Inner*, *Left Outer*, *Right Outer*, or *Full Outer* ), columns by which the tables should be joined, and a logical operator (*Equal to*, *Is less than*, or others) used to compare table columns.
57+
58+
![Query Builder: Join Editor](../../../../images/winforms-query-builder-join-editor.png)
59+
60+
You can manually join tables if they are not bound by a foreign key at the database level. In this case, when you drag-and-drop a table onto the **Query Builder** surface, the **Join Editor** is automatically invoked, and this editor allows you to construct a custom join relation.
61+
62+
![Query Builder: Create Relation Manually in the Join Editor](../../../../images/winforms-query-builder-create-relation-manually-in-the-join-editor.png)
63+
64+
> [!NOTE]
65+
> When you join multiple tables within a single SQL query, you create a flattened table composed of data records selected based on the specified join relations. You can also create [hierarchical data sources](TODO). In general, [master-detail reports](TODO) are generated faster than similar-looking reports created based on flattened data sources. If possible, use hierarchical data sources instead of flattened ones.
66+
67+
## Shape Data
68+
69+
The **Query Builder** displays a list of the query's columns at the bottom-right corner.
70+
71+
![Query Builder: List of Selected Table Columns](../../../../images/winforms-query-builder-list-of-selected-columns.png)
72+
73+
This list allows you to add new table columns to the query or shape selected table columns. The following options are available:
74+
75+
* **Column** - Specifies the selected column. Click the down-arrow button to display a drop-down column list and replace the column with another column. Click the ellipsis button to replace the column with an [expression](TODO).
76+
77+
![Query Builder: Specify an Expression for a Column](../../../../images/winforms-query-builder-specify-expression-for-column.png)
78+
79+
* **Table** - The table that contains the selected column. When you create an expression for a column, this option displays **(All Tables)**.
80+
81+
* **Alias** - A custom column name.
82+
83+
* **Output** - Specifies whether to include the column in the query's resulting set.
84+
85+
* **Sorting Type** - Specifies whether to keep the initial data record order (**Unsorted**) or sort the records by the column (**Ascending** or **Descending**).
86+
87+
> [!NOTE]
88+
> When you bind a report to an XML file, the **Query Builder** does not support sorting by aggregate functions, the *DISTINCT* and *SELECT ALL* statements, and manual SQL editing.
89+
90+
* Sort Order - Defines the sort order when data is sorted by multiple columns. For example, if column **A** has the sort order set to **1** and column **B** has it set to **2**, data records are first sorted by column **A** and then by column **B**. This option is available if you enable the **Sorting Type** option.
91+
92+
* **Group By** - Specifies whether to group the query's resulting set by this column.
93+
94+
* **Aggregate** - Specifies whether to apply an aggregate function to column values. The following aggregate functions are supported:
95+
96+
* Count
97+
* Max
98+
* Min
99+
* Avg
100+
* Sum
101+
* CountDistinct
102+
* AvgDistinct
103+
* SumDistinct
104+
105+
When you want to use the **Group By** or **Aggregate** operations, you should apply them either to all columns or none of them. When you use these operations, only the result of aggregation or grouping is included in the result set.
106+
107+
## Filter Data
108+
109+
Click the **Filter** button to invoke the **Filter Editor**.
110+
111+
![Query Builder: Click Filter Button](../../../../images/winforms-query-builder-click-filter-button.png)
112+
113+
![Query Builder: Filter Editor](../../../../images/winforms-query-builder-filter-editor.png)
114+
115+
The editor has the following tabs:
116+
117+
* **Filter Tab** - Allows you to build criteria to filter data for the report. Filter criteria can reference [query parameters](TODO), which you can also map to [report parameters](TODO).
118+
* **Group Filter Tab** - Allows you to specify filter conditions for grouped and aggregated data. This tab is disabled if the data is not grouped.
119+
120+
You can also enable the **Select only** option to limit the number of resulting data records. If you enable the **Sorting Type** option for at least one column, you can specify how many data records should be skipped.
121+
122+
> [!NOTE]
123+
> Some data providers do not support the skip setting in the provider-specific SQL string. If you enable the **Select only** option for such data providers, data records are skipped but the *SKIP* statement is not included in the SQL query.
124+
125+
The **Select only distinct values** option allows you to include only unique values into the resulting set.
126+
127+
## Edit Query Parameters
128+
129+
Click **Edit Parameters** to invoke the **Query Parameters** dialog.
130+
131+
![Query Builder: Click Edit Parameters Button](../../../../images/winforms-query-builder-click-edit-parameters-button.png)
132+
133+
This dialog allows you to add, edit, and remove [query parameters](TODO). The created parameters are available on the [Configure Query Parameters](TODO) wizard page.
134+
135+
![Query Builder: Query Parameters Dialog](../../../../images/winforms-query-builder-query-parameters-dialog.png)
136+
137+
The following properties are available for each query parameter:
138+
139+
* **Name** - The name by which you can reference the parameter.
140+
141+
* **Type** - The data type of the parameter's value.
142+
143+
* **Expression** - Specifies whether the parameter's value is static or generated dynamically. You can enable this option when you need to map the parameter's value to a [report parameter](TODO)'s value.
144+
145+
* **Value** - The parameter's value. If the **Expression** option is enabled, this value is generated dynamically based on the parameter's [expression](TODO).
146+
147+
Refer to the following topic for more information: [](TODO).
148+
149+
## Preview Results
150+
151+
Click the **Preview Results** button to open the **Data Preview** dialog.
152+
153+
![Query Builder: Preview Results Button](../../../../images/winforms-query-builder-preview-results-button.png)
154+
155+
The dialog displays the first 1000 rows of the query result set.
156+
157+
![Query Builder: Preview Results](../../../../images/winforms-query-builder-preview-results.png)
158+
159+
## Manage Queries
160+
161+
Right-click a data source in the [Report Explorer](TODO) or [Field List](TODO) and select **Manage Queries** in the context menu.
162+
163+
![Invoke the Manage Queries Dialog](../../../../images/winforms-invoke-manage-queries-dialog.png)
164+
165+
This invokes the **Manage Queries** dialog that allows you to perform operations on queries and stored procedures.
166+
167+
![Manage Queries Dialog](../../../../images/winforms-manage-queries-dialog.png)
168+
169+
### Add a New Query
170+
171+
Click **Add**, specify a name for the new query, and [select tables](#select-tables) that you want to include in the query.
172+
173+
![Manage Queries Dialog: Add a New Query](../../../../images/winforms-manage-queries-dialog-add-new-query.png)
174+
175+
### Copy and Remove Queries
176+
177+
Select a query and click the *Copy* or *Remove* icon.
178+
179+
![Manage Queries Dialog: Copy or Remove a Query](../../../../images/winforms-manage-queries-dialog-copy-or-remove-query.png)
180+
181+
### Modify Stored Procedures
182+
183+
Select an existing stored procedure and choose a new one that you want to include in a query.
184+
185+
![Manage Queries Dialog: Modify a Stored Procedure](../../../../images/winforms-manage-queries-dialog-modify-a-stored-procedure.png)
186+
187+
### Add a New Stored Procedure
188+
189+
Expand the **Add** menu and select **Stored Procedure**.
190+
191+
![Manage Queries Dialog: Add a Stored Procedure](../../../../images/winforms-manage-queries-dialog-add-a-stored-procedure.png)
192+
193+
### Rename a Query or Stored Procedure
194+
195+
Double-click an item in the list of queries and stored procedures and use the editor to specify a new name for this item.
196+
197+
![Manage Queries Dialog: Change an Item's Name](../../../../images/winforms-manage-queries-dialog-change-item-name.png)
198+
199+
# Query Builder (Old)
5200

6201
The **Query Builder** provides a visual interface for constructing SQL queries used to access database tables and views.
7202

12.9 KB
Loading
39.3 KB
Loading
39.3 KB
Loading
21.1 KB
Loading
32.7 KB
Loading
19.9 KB
Loading
13.3 KB
Loading
25.9 KB
Loading
145 KB
Loading

0 commit comments

Comments
 (0)