We often need the data window to display only the data we need. There are many ways to retrieve data in a data window, often by setting up setfilter and using SQL statements to implement it.
1, the use of setfilter data filtering
You first need to construct a conditional statement. If there is a column named Xyh in the Data window, we need to retrieve the xyh equals "Echufeng" data. Then the writable statements are as follows:
string bl;
Bl= "xyh= ' Echufeng '";
Dw_1.setfilter (BL)//Data window named Dw_1
Dw_1.retrieve ()//re-retrieve data
In this case, only the records XYH listed as "Echufeng" are displayed in the Data window. But sometimes we need to do more, so we need to use SQL.
2, using SQL statements to retrieve data
The Data window actually displays the results of the SQL statement as well. The Data window has a function setsqlselect, we can use this function to reassign the new query, so that the data window to display the data we need. Let's look at the following example:
int nhz;//defines an integer variable to be used to store statistics
Newsql= "select * from FY Where fy.xyh= ' Echufeng ';"; /Construct an SQL query
SELECT sum (FY.XHJ) into:nhz from FY WHERE Trim (fy.xyh) =:bl; Query, and Statistics XHJ columns
Dw_1.setsqlselect (Newsql)//Let the Data window execute a new query
st_2.text= "Total Cost" +string (nhz) + "Yuan". ";//Show Query results
Dw_1.retrieve ()//Don't forget to refresh
As you can see, after you reassign the SQL statement, you still need to retrieve the data using retrieve () to display the results we need.
The above we basically realize the data retrieval, we can write more powerful search query based on this idea, such as let the user specify the conditions of the query for a composite query, etc., here will not write more.
If you have any questions, please go to http://mapleafbutterfly.abc.yesite.com and tell me.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.