![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
ADOTable.Filter ? [D5, Access]
Tornado © (2002-10-23 08:59:00)Мастера, подскажите как отфильтровать данные при помощи 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 такое не прокатывает, подскажите как правильно написать. В хелпе не нашел. Спасибо
Tornado (2002-10-23 13:06:00) [1]> Андрей Прокофьев © (23.10.02 12:51)
спасибо !
sniknik (2002-10-23 13:05:00) [2]сорру я тоже ошибся
ADOTable1.Filter:= Field_s + "=""" + mxFlatEdit1.Text + #39;
Андрей Прокофьев (2002-10-23 12:51:00) [3]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);
Tornado (2002-10-23 12:44:00) [4]> sniknik © (23.10.02 12:15)
Field_s + "=""" mxFlatEdit1.Text + #39;
не работает. Ошибка "[Error] PhoneFilter.pas(107): Missing operator or semicolon"
sniknik (2002-10-23 12:15:00) [5]должно работать именнно так
но в этом примере ошибка 2 апострофа вместо трех, надо
Field_s + "=""" mxFlatEdit1.Text + #39;
(#39 это замена """")
Tornado (2002-10-23 10:55:00) [6]Всем огромное спасибо, особенно sniknik © (23.10.02 10:21). Ваш пример работает, я сделал фильтр "Начинается с ..." и "Содержит", а вот с "Равно" проблемы. Не могли бы кто нибудь из Мастеров подсказать как правильно написать. Я пишу так:
Field_s + "="" mxFlatEdit1.Text + """;
sniknik (2002-10-23 10:21:00) [7]так точно аботает
ADOTable1.Filter := Field_s+" Like """ + mxFlatEdit1.Text + "%""";
ADOTable1.Filtered := True;
IPisk (2002-10-23 10:17:00) [8]немного ошибся
ADOTable1.Filter := "name = """ + mxFlatEdit1.Text + """";
ADOTable1.Filtered := True;
IPisk (2002-10-23 10:15:00) [9]А если так
ADOTable1.Filter := "name = """" + mxFlatEdit1.Text + """";
ADOTable1.Filtered := True;
Tornado (2002-10-23 09:46:00) [10]> Anatoly Podgoretsky © (23.10.02 09:27)
Попробовал, не работает ни то ни другое, возвращает пустой набор...
Anatoly Podgoretsky (2002-10-23 09:27:00) [11]Попробуй вместо звездочки процент, а если и "Равно" не работает, то убрать скобки вокруг имени поля