How to Use filter to filter out empty query fields Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiDB/html/delphi_20061225155329114.html
To filter records whose field value is null
Paradox table, using query
Set filter: = 'field name = null'
Cannot Execute?
Filter: = 'field name in null'
Filter = 'fieldname is null'
In access, fieldname = NULL is written in this way.
It seems that is not good ^-^ !!!
Use =
as an example:
the data table structure is as follows: Table Name, temp
A Value Type
B text
Code :
with query1 DO
begin
close;
SQL. clear;
SQL. add ('select * from temp ');
filter: =' B = null';
filtered: = true; // It is estimated that you did not write this
open;
end;
B. If it is a text type, it cannot be used in sqlserver.
Use this judgment: datalength (B)> 0
Filter: = 'B = null ';
Filtered: = true; // It is estimated that you did not write this
Open;
No, I tried filtered: = true. I have already written
B is char type, and filter: = 'B = ''' is acceptable, but an error is returned when null is used.
Capbility can not supported
Is, in none
Paradox table
Create a new table as shown in my example,
The data table structure is as follows: Table Name, temp
Field name a numeric type primary key
Field name B text
The database is a paradox table.
Enter some test data
Create a project in Delphi. Do not use the code below. But there is no problem on my machine.
The Code is as follows:
With query1 do
Begin
Close;
SQL. Clear;
SQL. Add ('select * from temp ');
Filter: = 'B = null ';
Filtered: = true; // It is estimated that you did not write this
Open;
End;
You can create a new table,
I will try again to find the reason,
In addition, how to filter out records that are null or trim (filed. Value) = ''?
The field is null, which can be
Find the cause. When the SQL statement is added with the where condition and the condition is date type, and the parambyname () of the query is used as the method for passing parameters, the null error is used, instead of sdate =: if you add sd1 directly, no error will occur if you use NULL for filtering.