Retrieve data in the data window

zhaozj2021-02-08  198

Retrieve data in the data window

We tend to require only the data we need. The way to retrieve data in the data window is much, often used to set the setfilter and use the SQL statement to be implemented.

1. Use SetFilter to filter data filtering

First need to construct the conditional statement. If there is a column named XYH in the data window, we need to retrieve the data of XYH equal to "Ye Qiufeng". Then the writable statement is as follows:

String BL; BL = "XYH = 'Ye Qiufeng'"; DW_1.SETFILTER (BL) // Data window named DW_1DW_1.Retrieve () // Retrieval data

In this way, only the XYH recording is displayed as "Ye Qiufeng". But sometimes we need to do more, so you need to use SQL.

2. Use the SQL statement to retrieve data

The data window is actually the result of the SQL statement. There is a function setsqlselect, we can use this function to reset a new query to let the data window to display the data we need. Let's look at the example below:

INT NHZ; / / Define a integer variable, ready to store statistics newsql = "SELECT * from fy where fy.xyh = 'Ye Qiufeng';"; // Construct a SQL query Select SUM (Fy.xhj) INTO: NHz from fy where trim (fy.xyh) =: BL; // query, and statistics XHJ column DW_1.setsqlselect (newsql); // Let the data window execute new query st_2.text = "co-fees" string (NHz ) "Yuan."; // Show query results dw_1.Retrieve (); // Never forget refresh

It can be seen that retrieve () can still be retrieved after the SQL statement will be retrieved.

We basically realize data search, you can write a stronger search query according to this idea, such as letting users specify the condition of the query, etc., this is no longer written here.

If you have any questions, please tell me at http://mApleafbutterfly.abc.yesite.com.

转载请注明原文地址:https://www.9cbs.com/read-2856.html

New Post(0)