Answer the question
In order to leave comments, you need to log in
ADOTable filter. How to filter integers?
Good day, Khabrchane.
Please help me to solve the following problem.
Delphi 7 programming environment. Database - MS SQL Server 2008 R2.
There is an ADOTable component. Through it, filtering of the table is organized by the ADOTable.Filter property.
Data of type varchar is filtered without problems, but there is a snag with integers. When you enter a number, it displays the message "Cannot open the filter."
Filter code:
procedure TForm1.Filter;
var filtr,add:string;
begin
Table.Filtered:=false;
filtr:='';
if length(IDed.Text)>0 then
filtr:='id LIKE '+#39+IDed.Text+'%'+#39;
if length(DeEd.Text)>0 then
begin
if length(filtr)>0 then
add:=' AND '
else add:='';
filtr:=filtr+add+'descr LIKE '+#39+DeEd.Text+'%'+#39;
end;
if length(DLEd.Text)>0 then
begin
if length(filtr)>0 then
add:=' AND '
else add:='';
filtr:=filtr+add+'deadline LIKE '+#39+DLEd.Text+'%'+#39;
end;
if length(DLEd.Text)>0 then
begin
if length(filtr)>0 then
add:=' AND '
else add:='';
filtr:=filtr+add+'deadline LIKE '+#39+DLEd.Text+'%'+#39;
end;
if length(PEd.Text)>0 then
begin
if length(filtr)>0 then
add:=' AND '
else add:='';
filtr:=filtr+add+'priorit LIKE '+#39+PEd.Text+'%'+#39;
end;
if length(GrEd.Text)>0 then
begin
if length(filtr)>0 then
add:=' AND '
else add:='';
filtr:=filtr+add+'groupT LIKE '+#39+GrEd.Text+'%'+#39;
end;
if length(DendEd.Text)>0 then
begin
if length(filtr)>0 then
add:=' AND '
else add:='';
filtr:=filtr+add+'dateEnd LIKE '+#39+DendEd.Text+'%'+#39;
end;
if length(filtr)>0 then
begin
Table.Filter:=filtr;
Table.Filtered:=true;
end;
end;
Answer the question
In order to leave comments, you need to log in
The solution was found in the fresh air. When I got home, I quickly started checking. And what do you think? Everything is working!
The point is that the problem was not in the data types, but in the syntax of the filter request, or rather in the "%" sign.
I can’t exactly give the code of the program yet, but now at least everything is clear.
And yes, be outdoors more often =)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question