Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.47 MB
Время: 0.011 c
3-33866
Blunder
2002-10-18 21:22
2002.11.11
conversion from string


14-34164
Spirit.
2002-10-24 18:33
2002.11.11
Помогите типизированые файлы в Delphi.


6-34154
Metallica
2002-09-07 18:18
2002.11.11
Как проверить существование страницы в интернет, используя NMHTTP


14-34245
kull
2002-10-22 14:53
2002.11.11
SQL Precompiler...


14-34177
MBo
2002-10-21 12:55
2002.11.11
Длинный гудок на маме - что значит?




   Наверх