Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.11.11;
Скачать: CL | DM;

Вниз

ADOTable.Filter ?   Найти похожие ветки 

 
Tornado ©   (2002-10-23 08:59) [0]

Мастера, подскажите как отфильтровать данные при помощи ADOTable.Filter. Раньше использовал компонент KADAO, там фильтр организовывался следующим образом:

"Равно (точное совпадение)"


Field_s := "name";
ADOTable1.Filter := "[" + Field_s +"] = "" + mxFlatEdit1.Text + """;
ADOTable1.Filtered := True;


"Содержит"

ADOTable1.Filter := "[" + Field_s +"] Like "*" + mxFlatEdit1.Text + "*"";
ADOTable1.Filtered := True;


"Начинается с..."

ADOTable1.Filter := "[" + Field_s +"] Like "" + mxFlatEdit1.Text + "*"";
ADOTable1.Filtered := True;


С ADO такое не прокатывает, подскажите как правильно написать. В хелпе не нашел. Спасибо


 
Anatoly Podgoretsky ©   (2002-10-23 09:27) [1]

Попробуй вместо звездочки процент, а если и "Равно" не работает, то убрать скобки вокруг имени поля


 
Tornado ©   (2002-10-23 09:46) [2]

> Anatoly Podgoretsky © (23.10.02 09:27)

Попробовал, не работает ни то ни другое, возвращает пустой набор...


 
IPisk ©   (2002-10-23 10:15) [3]

А если так


ADOTable1.Filter := "name = """" + mxFlatEdit1.Text + """";
ADOTable1.Filtered := True;


 
IPisk ©   (2002-10-23 10:17) [4]

немного ошибся


ADOTable1.Filter := "name = """ + mxFlatEdit1.Text + """";
ADOTable1.Filtered := True;


 
sniknik ©   (2002-10-23 10:21) [5]

так точно аботает
ADOTable1.Filter := Field_s+" Like """ + mxFlatEdit1.Text + "%""";
ADOTable1.Filtered := True;


 
Tornado ©   (2002-10-23 10:55) [6]

Всем огромное спасибо, особенно sniknik © (23.10.02 10:21). Ваш пример работает, я сделал фильтр "Начинается с ..." и "Содержит", а вот с "Равно" проблемы. Не могли бы кто нибудь из Мастеров подсказать как правильно написать. Я пишу так:

Field_s + "="" mxFlatEdit1.Text + """;


 
sniknik ©   (2002-10-23 12:15) [7]

должно работать именнно так
но в этом примере ошибка 2 апострофа вместо трех, надо
Field_s + "=""" mxFlatEdit1.Text + #39;
(#39 это замена """")


 
Tornado ©   (2002-10-23 12:44) [8]

> sniknik © (23.10.02 12:15)

Field_s + "=""" mxFlatEdit1.Text + #39;


не работает. Ошибка "[Error] PhoneFilter.pas(107): Missing operator or semicolon"


 
Андрей Прокофьев ©   (2002-10-23 12:51) [9]

The filter expression below displays only those rows where the State field is "CA" or "MA":

State = "CA" OR State = "MA"

The following runtime example shows how to assign that filter expression to the Filter property and activate the filtering.

with ADODataSet1 do begin

Filtered := False;
Filter := "State = " + QuotedStr("CA") + " OR " +
"State = " + QuotedStr("CA");
Filtered := True;

end;

When a filter is set, Blank records do not appear unless explicitly included in the filter. To include rows based on blank, (or "NULL") values in table columns, compare the column to NULL in the expression. For example:

with ADODataSet1 do begin

Filtered := False;
Filter := "State = " + QuotedStr("CA") + " OR " +
"State = NULL";
Filtered := True;

end;

Tip: Applications can set Filter at runtime to change the filtering condition for a dataset at (for example, in response to user input).
Note: include a space between comparison values and comparison operators in filter expressions. For instance, ensure that there is a space after the field name and before the operator.

Field_s + " = " + QuotedStr(mxFlatEdit1.Text);





 
sniknik ©   (2002-10-23 13:05) [10]

сорру я тоже ошибся
ADOTable1.Filter:= Field_s + "=""" + mxFlatEdit1.Text + #39;



 
Tornado ©   (2002-10-23 13:06) [11]

> Андрей Прокофьев © (23.10.02 12:51)

спасибо !



Страницы: 1 вся ветка

Текущий архив: 2002.11.11;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.012 c
3-33888
Higs
2002-10-22 16:17
2002.11.11
Uniqueidetifier в MS SQL


1-33970
Z_man7777
2002-11-01 13:13
2002.11.11
Какой будет тип возвращаемый функцией?


3-33905
NeyroSpace
2002-10-21 17:16
2002.11.11
Как сконвертировать VARCHAR(х) в Blob?


1-33995
Andrey1
2002-11-01 16:58
2002.11.11
FastReport (Delphi 6)


1-34080
Anonimus
2002-10-30 14:18
2002.11.11
Как узнать в какой кодировке находиться файл....