PC SOFT

WINDEV的在线文档

  • Overview
  • Creating a report on an SQL query on file via a connection
  • Printing a report based on an SQL query via a connection
  • WinDev and WebDev example
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系:info@cn.windev.com
产品
WinDevWebDev-服务器代码WebDev-浏览器代码WinDev Mobile报表和查询
平台
WindowsLinuxWindows MobileWindows PhoneWindows Store appsAndroidAndroid Widget iPhone/iPad
语言
JavaPHPAjax用户代码(MCU)外部语言
数据库
HFSQLHFSQL Client/Server存储过程HF 5.5OLE DBODBC本地访问

Report on an SQL query performed on a connection (ODBC, ...)

Overview
A report on an SQL query via a connection is used to print the records coming from a database accessible via a specific ODBC driver or via a Native Access. This query is defined when creating the report.

Note: To optimize the resources used on a Mobile Device (Pocket PC), printing a report based on an SQL query via a connection is not available in WinDev Mobile.

Characteristics of a report based on an SQL query via a connection:

  • the connection parameters (name of the connection, name of the user, ...). These parameters allows you to access the records that will be printed in the report.
    For an ODBC connection, the parameters are defined in the ODBC administrator (in the control panel of Windows).
    For a connection via Native Access, the parameters are defined when configuring the database.
  • the SQL code of the query associated with the report. This code must correspond to a Select query ("SELECT"). This query is used to specify the items that will be printed in the report.
Caution: The SQL code must be recognized by the database accessed.

The creation of a report based on an SQL query via a connection is performed by the wizard for report creation.

Once the report on an SQL query via a connection is created, you can:

  • modify the SQL code of the query ("Data" tab in the report description).
  • modify the parameters of the connection ("Data" tab of the report description).
  • add or delete Item controls linked to the SQL query associated with the report.

Creating a report on an SQL query on file via a connection
To create a report on an SQL query on file via a connection:
  1. Select "File .. New .. Report". The wizard for report creation starts.Clickamong the quick access buttons.
    • Click "Report" in the wheel that is displayed.The window for creating a new element is displayed: click "Report" then "Report".
    • The wizard for report creation starts.
  2. Choose the layout of your report (table, form, label, ...). See The different types of reports for more details.
  3. Select the data source of the report ("From a SQL query by connection").
  4. Select the type of connection to use (ODBC or Native Access)
  5. Specify the connection parameters:
    • the name of the connection.
    • the name of the user.
    • the password of the user.
    • the name of the database accessed (if there is more than one).
  6. Enter the SQL code of the query associated with the report.
    Caution: The SQL code must be recognized by the database accessed.
  7. To group the records, you have the ability to create breaks on the sort items. To create breaks, answer "Yes" to the question "Do you want to add breaks into the report".
    The next step is used to select the sort items corresponding to the breaks. See Breaks in a report for more details.
  8. For each query item displayed in the report:
    • enter the corresponding caption. This caption will be displayed:
      • before the item. For example:
      • in the header of the column (for the Table reports). For example:
        This caption can be modified in the report editor.
    • select the block where the control associated with the item must be printed. The positions of the different controls can be modified in the report editor. See Report blocks for more details.
  9. Modify (if necessary) the display order of the controls in the report with the arrow buttons found on the right of the table.
  10. Depending on the type of report currently created, indicate the specific options.
    Type of reportSpecific options
    Type of report: Table + ChartType of the chart, aspect of the chart, ...
    Options presented in Table + Chart report
    Chart reportType of the chart, aspect of the chart, ...
    Options presented in Chart report
    Report on formImage of the form, print the image of the form, ...
    Options presented in Report on form
    Label reportFormat of labels, number of identical copies, ...
    Options presented in Label report

    Type of reportSpecific options
    Report on formImage of the form, print the image of the form, ...
    Options presented in details in Report on form
    Label reportFormat of labels, number of identical copies, ...
    Options presented in Label report
  11. Specify the format of the sheet on which the report will be printed. The report is printed in A4 format by default.
  12. Select the skin template of the report if necessary.
  13. Enter the name and title of the report (name of the ".WDE" file corresponding to the report). This name will be used to identify the report in your programs.
  14. Validate the report creation.
  15. The report editor automatically proposes to change the format of the report if the following conditions are fulfilled:
    • the report currently created includes a table.
    • the report format does not allow to display all the table columns.
  16. Specify (if necessary) the mode for reducing the report size:
    • 19版本和更高版本
      Print the report on several pages. In this case, the end user will have to group the pages. See Multi-page print for more details.
      19新版本
      Print the report on several pages. In this case, the end user will have to group the pages. See Multi-page print for more details.
      Print the report on several pages. In this case, the end user will have to group the pages. See Multi-page print for more details.
    • Use the landscape mode.
    • Reduce the size of the report. Caution: according to the reduction percentage, the printed report may become unreadable.
  17. The report currently created is displayed in the report editor.

Printing a report based on an SQL query via a connection
To print a report based on a SQL query via a connection, you must:
  1. Configure the destination of the report print:
  2. Specify the name of the report to print with 打印报表.
Notes:

ImportantIn Reports & Queries, a report can be printed:
  • by starting a print ().
  • by running the report test ().
Therefore, no programming is required to print the report.

WinDevWindows

WinDev and WebDev example

The "REPORT_Customer" report is based on a SQL query built on the Access "Customer" database. This database is accessed via the ODBC driver of Access. By default, this report is used to print all the characteristics of the customers.

The user can:

  • click the "BTN_CustomerCharacteristics" button to print all the characteristics of the customer. The SQL code of the query will not be modified.
  • click the "BTN_CustomerNames" button to print the first name and last name of customers. The SQL code of the query will be modified.
To find out whether the SQL code of the query must be modified or not, a parameter is passed to the report:
  • "True": no modification of the SQL code.
  • "False": modification of the SQL code.
In this example:
  • the click code of the "BTN_CustomerCharacteristics" button is as follows:
    • WinDev WinDev code:
      // Open the preview window
      打印预览()
      // Print the report while passing parameters
      打印报表RPT_Customer"True"
  • the click code of the "BTN_CustomerFNameLName" button is as follows:
    • WinDev WinDev code:
      // Open the preview window
      打印预览()
      // Print the report while passing parameters
      打印报表RPT_Customer"False"
  • the code of the "Open" process for the "REPORT_Customer" is as follows:
    // Retrieve the parameter passed to the report
    过程RPT_CustomerChoice
    如果Choice"False",那么
    // Modify the SQL code
    RPT_Customer..ODBCSQL代码="Select LastName, FirstName FROM Customer"
    结束