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

Вниз

Фильтраия по 2 и более полям   Найти похожие ветки 

 
IntruderLab ©   (2006-06-26 14:22) [0]

Ситуация такая, мне необходимо сделать фильрацию для TADOTable по двум значениям, значения выбираются из LooucpComboBox (что не так важно), но тем не менее хочеться, чтобы фильтрация была по двум значениям:

пример

adotTable.Filtered := False;
adotTable.Filter := cbOne.KeyField + ";" + cbTwo.KeyFieldl
adotTable.Filtered := True;

данный пример не работает, как добиться подобного?


 
IntruderLab ©   (2006-06-26 14:27) [1]

Сразу скажу, что можно применить TADOQwery, но просто не хочу :) если нет вариантов, конечно использую SQL запрос в ADOQwery


 
Vlad ©   (2006-06-26 14:36) [2]

Справку уже читали?


 
IntruderLab ©   (2006-06-26 15:15) [3]

к несчатьюЮ справки стандартной делфи у меня на компе сейчас нет..


 
Sergey13 ©   (2006-06-26 15:17) [4]

> [3] IntruderLab ©   (26.06.06 15:15)
> к несчатьюЮ справки стандартной делфи у меня на компе сейчас
> нет..

Будет - посмотри. Интересно.


 
Vlad ©   (2006-06-26 15:26) [5]

Высылаю.
---------------------------------------------------------

Filter property (TCustomADODataSet)

Specifies the text of the current filter for a recordset.

Delphi syntax:

property Filter: String;

C++ syntax:

__property AnsiString Filter = {read=FFilterText, write=SetFilterText};

Description

Use Filter to specify a recordset filter. When filtering is applied to a recordset by setting the Filtered property to true, only those records that meet a filter’s conditions are available to the application. Filter contains the expression used to evaluate the rows in the recordset. At design-time, enter the filter expression into the editing cell for the Filter property within the Object Inspector. At runtime, assign a string containing the filter expression to the Filter property.

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;
ADODataSet1->Filtered = false;
ADODataSet1->Filter = "State = " + QuotedStr("CA") + " OR " + "State = " + QuotedStr("CA");
ADODataSet1->Filtered = true;

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;
ADODataSet1->Filtered = false;
ADODataSet1->Filter = "State = " + QuotedStr("CA") + " OR " + "State = NULL";
ADODataSet1->Filtered = true;

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.


 
molodoi ©   (2006-06-27 16:47) [6]

Когда догадаешься, обязательно в фильтре используй скобки, а то фильтр не заработает.

Типа:

Filter = "Field1 = ("+QuotedStr(Edit1.Text)+" AND ("+QuotedStr(Edit2.Text)+"))";


 
Fay ©   (2006-06-28 09:38) [7]

2 molodoi ©   (27.06.06 16:47) [6]
Прикольный фильтр получится 8)



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

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

Наверх




Память: 0.48 MB
Время: 0.041 c
2-1155298868
dera
2006-08-11 16:21
2006.09.03
Как узнать, что форма свернута (развернута)?


15-1154685063
QuickFinder
2006-08-04 13:51
2006.09.03
Пятничная задачка


15-1154946124
Сатир
2006-08-07 14:22
2006.09.03
Проблема с загрузкой письма в компонент Indy


6-1144821895
DelphiN!
2006-04-12 10:04
2006.09.03
Размер сетевого TCP/IP пакета


1-1153462892
ANB
2006-07-21 10:21
2006.09.03
Как вытащить истинный путь к файлу ?