![]() |
Custom View Setup Custom View allows you to save your SELECT statements in a project and use the results like normal tables. If your database, for example, MySQL 4, does not support views, you'll find this feature extremely useful. Even if your database support views, you'll also find it handy as you can create different versions of ASP.NET pages with Custom Views for the same table/view in a single project. A Custom View is basically a SELECT statement. Custom Views give you an option to save your SELECT statements right within the ASP.NET Report Maker interface, they are, however, not to replace views provided by the database. Views provided by database allow you to use them like regular tables, though views are usually not updatable. Also, query builder provided by database itself, for example, that provided by Access or SQL Server, ensures that the generated SQL is 100% compatible with the database. You should always use views provided by your database whenever available. After loading the database in ASP.NET Report Maker, the database objects (tables, views, custom views and reports) will be shown in the left pane (the database pane). To create a custom view, right click the database pane and select [Add Custom View]. Alternatively, you can click [Edit] in the main menu and then select [Add Custom View]. The Custom View Setup window will show up:
ASP.NET Report Maker will give the new Custom View a temporary name, CustomView<n>, where n is an integer. If you want to change the name, enter a new name in the [Custom View name] edit box in the main toolbar. It is recommended that the built-in visual query builder be used to build your SQL. The query builder interface is intuitive and fully supports drag-n-drop, in most cases you don't need to type the table or field names. On the left hand side, the available tables are displayed in the table pane. On the right hand side, there are three tabs: [Builder], [SQL] and [Result]. (The [Result] tab will only be visible after you execute the SQL.)
Builder To build your SQL, drag your tables from the table pane on the left to the builder area and check the required fields.
To create joins, drag a field from one table to its linked field in an other table.
If you need to add criteria (WHERE clauses), click the small [...] button on the [Criteria] tab and select [Add condition]. A blank condition will appear, you can enter a field to the left side by any of the following ways:
Then you can enter your condition to the right side. Repeat for more conditions. You can make composite conditions (using AND, OR, etc. for conditions) by clicking the number button of an existing condition and then [Make composite condition] to add another condition. In the [Selection] tab, you can choose to use DISTINCT, change aliases, add aggregates (and hence a GROUP BY clause) for fields. In the [Sorting], you can build your ORDER BY clause easily. When necessary, you can click [View] and then [Query Builder Options...] to enable the [Grouping Criteria] tab which allowing you to build a HAVING clause for your SQL. There are many other options for the query builder in the options dialog box, but usually you don't need to change them.
SQL You can always click the [SQL] tab to check the SQL generated by the query builder, the SQL editor is also syntax-highlighted to enhance the readability of the SQL.
The SQL tab is actually an SQL editor, you can type your SQL directly without using the query builder here, or paste your SQL from elsewhere, or open a saved SQL script (*.sql) from file.
Result When you have finished your SQL, you can test the SQL by any one of the following ways:
The [Result] tab will become visible and display the result data. If the data is correct, the Custom View setup is almost done. Since a Custom View is based on an existing table, there is an option that the fields in the Custom View use the same Field Setup (e.g. View Tag settings) as the source table. If you want to copy field settings, check the checkbox [Copy field settings from source table (when applicable)]; if not, uncheck it. Then you can press [OK] to finish.
When a Custom View is added, ASP.NET Report Maker will load it and display it in the database pane and Table Setup page under the [Custom Views] node. To view the SELECT statement of the Custom View, right click the Custom View in database pane and select [Object Properties]. Alternatively, you can select the Custom View first, then click [Project] in the main menu and then select [Object Properties]. To edit a custom view, right click the Custom View in the database pane and select [Edit Custom View]. Alternatively, you can select the Custom View first, then click [Edit] in the main menu and then select [Edit Custom View]. When a Custom View is added or edited, ASP.NET Report Maker will check the SQL. If the SQL is invalid, the icon of the Custom View will have a cross on it like
Important Notes on Custom Views
|
| ©2007 e.World Technology Ltd. All rights reserved. |