Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Базы";
Текущий архив: 2006.09.03;
Скачать: [xml.tar.bz2];

Вниз

Фильтраия по 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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.036 c
2-1155490605
learner
2006-08-13 21:36
2006.09.03
Использование Result как локальной переменной в функции


1-1153655572
P_Alex
2006-07-23 15:52
2006.09.03
XLReport 4


2-1155626458
barakuda
2006-08-15 11:20
2006.09.03
EhLib+фильтрация


2-1155723451
Батыр
2006-08-16 14:17
2006.09.03
Отправка писем


15-1155120778
Аноним
2006-08-09 14:52
2006.09.03
Вопрос





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский