Этот баннер — требование Роскомнадзора для исполнения 152 ФЗ.
«На сайте осуществляется обработка файлов cookie, необходимых для работы сайта, а также для анализа использования сайта и улучшения предоставляемых сервисов с использованием метрической программы Яндекс.Метрика. Продолжая использовать сайт, вы даёте согласие с использованием данных технологий».
Политика конфиденциальности
|
|
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Раньше, при работе в DAO я использовал для многокритериального поиска в таблице базы по разным полям запрос: strSQL = "SELECT * FROM Components WHERE Components.Model Like " & "'*" & Text7.Text & "*'" & Two & Tri & Chet & Second Переменные Two, Tri, Chet, Second формируются аналогично с помощью Like. Можно ли производить такой же многокритериальный поиск по различным полям при использовании ADO. Ну, например, так (не работает): sCriteria = "Model Like " & "'*" & Text7.Text & "*'" & Two & Tri & Chet & Second & "order by Name" adors.Find sCriteria, adSearchForward или по другому? У меня в ADO ничего не получается. Помогите! ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 29.08.2004, 13:43 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Я тебе кусок из своего приложения выдернул. Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 29.08.2004, 18:13 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Спасибо, Максим! Буду разбираться. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 30.08.2004, 12:36 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Максим! Насколько я понял, поиск идет все-таки по одному параметру cboSample.Text ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 30.08.2004, 13:02 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Мне надо производить одновременный многокритериальный поиск в таблице по различным полям (Model, Autor, KeyWord и т.д.). Переменные определяются вводимым при поиске содержимым текстовых полей: Two = " AND Autor LIKE " & "'*" & Text8.Text & "*'" If Text8.Text = Empty Then Two = Empty If Check2.Value = 0 Then Two = Empty Tri = " AND KeyWord LIKE " & "'*" & Text9.Text & "*'" If Text9.Text = Empty Then Tri = Empty If Check3.Value = 0 Then Tri = Empty Chet = " AND KeyWord LIKE " & "'*" & Text10.Text & "*'" If Text9.Text = Empty Then Chet = Empty If Check4.Value = 0 Then Chet = Empty Second = " AND Firm LIKE " & "'*" & Combo1.Text & "*'" If Combo1.Text = Empty Then Second = Empty If Check5.Value = 0 Then Second = Empty В DAO это у меня работает, в ADO - нет! А как сделать, пока нигде не нашел ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 30.08.2004, 13:17 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
используй % вместо * EX: AND Autor LIKE " & "'%" & Text8.Text & "%'" ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 30.08.2004, 13:35 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
cboSample.Text содержит следующее: Код: plaintext Код: plaintext ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 30.08.2004, 14:35 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Нет, что-то у меня ничего не катит :(. Перепробовал разные варианты, например: sCriteria = "Name Like '%" + "as%' " '+ "Autor Like '%" + "ar%' " ' & Text2.Text & "%'" '& "Autor Like " & "'%" & Text1.Text & "%'" sCriteria = "Name Like " & "'*" & Text2.Text & "*'" '& "Autor Like " & "'*" & Text1.Text & "*'" adors.MoveFirst While adors.EOF = False adors.Find sCriteria, adSearchForward List2.AddItem adors.Fields("Name") adors.MoveNext Wend По одному полю ищет без проблем. Как только добавляю поск по другому полю - перестает искать совсем. Выдает все записи. Может что-нибудь подскажете? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 01.09.2004, 16:20 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
К чему конекимся? Сиквел? В последнем варианте между параметрами должно быть AND, теретически :). Выкинь содержимое строки поиска после формирования. Magnus ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 01.09.2004, 16:36 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Должно быть так(работает и в Access и MSSQL): Код: plaintext Magnus32: ты где пропадал? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 01.09.2004, 19:04 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Пардон, одни "кавычки" пропустил. Да, и Access 2000. Код: plaintext ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 01.09.2004, 19:38 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
О чем шумим ,братцы? Find в ADO работет только с одним полем. Для поиска по нескольким полям надо использовать метод Filter ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 01.09.2004, 20:33 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
МаксимВДолжно быть так(работает и в Access и MSSQL): Код: plaintext Magnus32: ты где пропадал? На работе собсно :), новый проэкт, голову некогда поднять. Вот пришел (c)VIG и испортил весь поспитательный процесс :). Низя так сразу. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 01.09.2004, 21:19 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
авторВот пришел (c)VIG и испортил весь поспитательный процесс :). Низя так сразу. Платон мне друг, но истина дороже! (не мое) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 01.09.2004, 22:06 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Спасибо всем! Сегодня - завтра некогда прог-ить - совещаемся с заказчиками. Но, видимо, (c)VIG прав? Все это работает в DAO. A в ADO облом! Буду разбираться ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 02.09.2004, 11:07 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
авторНо, видимо, (c)VIG прав? Не "видимо" ,а абсолютно :) Find Method Searches a Recordset for the row that satisfies the specified criteria. Optionally, the direction of the search, starting row, and offset from the starting row may be specified. If the criteria is met, the current row position is set on the found record; otherwise, the position is set to the end (or start) of the Recordset. Syntax Find (Criteria, SkipRows, SearchDirection, Start) Parameters Criteria A String value that contains a statement specifying the column name, comparison operator, and value to use in the search. SkipRows Optional. A Long value, whose default value is zero, that specifies the row offset from the current row or Start bookmark to begin the search. By default, the search will start on the current row. SearchDirection Optional. A SearchDirectionEnum value that specifies whether the search should begin on the current row or the next available row in the direction of the search. An unsuccessful search stops at the end of the Recordset if the value is adSearchForward. An unsuccessful search stops at the start of the Recordset if the value is adSearchBackward. Start Optional. A Variant bookmark that functions as the starting position for the search. Remarks Only a single-column name may be specified in criteria. This method does not support multi-column searches . The comparison operator in Criteria may be ">" (greater than), "<" (less than), "=" (equal), ">=" (greater than or equal), "<=" (less than or equal), "<>" (not equal), or "like" (pattern matching). The value in Criteria may be a string, floating-point number, or date. String values are delimited with single quotes or "#" (number sign) marks (for example, "state = 'WA'" or "state = #WA#"). Date values are delimited with "#" (number sign) marks (for example, "start_date > #7/22/97#"). If the comparison operator is "like", the string value may contain an asterisk (*) to find one or more occurrences of any character or substring. For example, "state like 'M*'" matches Maine and Massachusetts. You can also use leading and trailing asterisks to find a substring contained within the values. For example, "state like '*as*'" matches Alaska, Arkansas, and Massachusetts Asterisks can be used only at the end of a criteria string, or together at both the beginning and end of a criteria string, as shown above. You cannot use the asterisk as a leading wildcard ('*str'), or embedded wildcard ('s*r'). This will cause an error.. Note An error will occur if a current row position is not set before calling Find. Any method that sets row position, such as MoveFirst, should be called before calling Find. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 02.09.2004, 13:52 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
(c)VIG[quot автор]Но, видимо, (c)VIG прав? Не "видимо" ,а абсолютно :) [quot ][quot] Спасибо, прочувствовал. Наскороту попробовал метод Filter - тоже не пропер по второму полю. Но эксперементировать некогда - лужу усеченную однокритериальную версию, чтобы в понедельник показать заказчику. Хотя вся прелесть программы исчезает. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 02.09.2004, 14:19 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Мне что ,весь хелп скопировать? :) Filter Property Indicates a filter for data in a Recordset. Settings and Return Values Sets or returns a Variant value, which can contain one of the following: Criteria string — a string made up of one or more individual clauses concatenated with AND or OR operators. Array of bookmarks — an array of unique bookmark values that point to records in the Recordset object. A FilterGroupEnum value. Remarks Use the Filter property to selectively screen out records in a Recordset object. The filtered Recordset becomes the current cursor. Other properties that return values based on the current cursor are affected, such as AbsolutePosition, AbsolutePage, RecordCount, and PageCount. This is because setting the Filter property to a specific value will move the current record to the first record that satisfies the new value. The criteria string is made up of clauses in the form FieldName-Operator-Value (for example, "LastName = 'Smith'"). You can create compound clauses by concatenating individual clauses with AND (for example, "LastName = 'Smith' AND FirstName = 'John'") or OR (for example, "LastName = 'Smith' OR LastName = 'Jones'"). Use the following guidelines for criteria strings: FieldName must be a valid field name from the Recordset. If the field name contains spaces, you must enclose the name in square brackets. Operator must be one of the following: <, >, <=, >=, <>, =, or LIKE. Value is the value with which you will compare the field values (for example, 'Smith', #8/24/95#, 12.345, or $50.00). Use single quotes with strings and pound signs (#) with dates. For numbers, you can use decimal points, dollar signs, and scientific notation. If Operator is LIKE, Value can use wildcards. Only the asterisk (*) and percent sign (%) wild cards are allowed, and they must be the last character in the string. Value cannot be null. Note To include single quotation marks (') in the filter Value, use two single quotation marks to represent one. For example, to filter on O'Malley, the criteria string should be "col1 = 'O''Malley'". To include single quotation marks at both the beginning and the end of the filter value, enclose the string with pound signs (#). For example, to filter on '1', the criteria string should be "col1 = #'1'#". There is no precedence between AND and OR. Clauses can be grouped within parentheses. However, you cannot group clauses joined by an OR and then join the group to another clause with an AND, like this: (LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John' Instead, you would construct this filter as (LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John') In a LIKE clause, you can use a wildcard at the beginning and end of the pattern (for example, LastName Like '*mit*'), or only at the end of the pattern (for example, LastName Like 'Smit*'). The filter constants make it easier to resolve individual record conflicts during batch update mode by allowing you to view, for example, only those records that were affected during the last UpdateBatch method call. Setting the Filter property itself may fail because of a conflict with the underlying data (for example, a record has already been deleted by another user). In such a case, the provider returns warnings to the Errors collection but does not halt program execution. A run-time error occurs only if there are conflicts on all the requested records. Use the Status property to locate records with conflicts. Setting the Filter property to a zero-length string ("") has the same effect as using the adFilterNone constant. Whenever the Filter property is set, the current record position moves to the first record in the filtered subset of records in the Recordset. Similarly, when the Filter property is cleared, the current record position moves to the first record in the Recordset. See the Bookmark property for an explanation of bookmark values from which you can build an array to use with the Filter property. Only Filters in the form of Criteria Strings (e.g. OrderDate > '12/31/1999') affect the contents of a persisted Recordset. Filters created with an Array of Bookmarks or using a value from the FilterGroupEnum will not affect the contents of the persisted Recordset. These rules apply to Recordsets created with either client-side or server-side cursors. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 02.09.2004, 14:26 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
(c)VIG! Ну, не ругайся ты! Поясню ситуацию. Я не проф. программист. Начинал с VB1-DOS. Лужу чисто прикладные свои (связные) задачки. Основная моя работа - оборудование мобильной связи. Перешел постепенно на VB6 (Поднялся :)). Пользуюсь парой книг по Access и VB6(Программирование БД). Пока хватало. А Help, который ты дерешь, я даже не знаю откуда. Ты уж извини за напряг. Спасибо, успехов! ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 02.09.2004, 14:43 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Radist(c)VIG! Ну, не ругайся ты!../quot] Там вроде бы смайлик был [quot автор]Help, который ты дерешь, я даже не знаю откуда. Ну ,если на компьютере не установлен ,то можно отсюда Удачи! ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 02.09.2004, 15:20 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Да, я когда купил VB6, там в пакете не было Helpa вообще. Так и юзаю с хелпом от VB4. По поводу смайлика. Сижу слегка задрюченный от заморочек и недосыпов - не обратил внимания - извини! Ну и маленькая история для разрядки в тему. Сын мне тут прислал SMS-ку. "Как ты отнесешься к тому, что я приду домой, не такой как уходил?" В свете последних событий я, получив ее чуть с ума не сошел. Звоню ему, а он говорит - "Ты что! Там же в конце я смайлик поставил!". Спасибо за помощь! Лужу дальше. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 02.09.2004, 15:43 |
|
||
|
Поиск по различным полям таблицы БД в ADO
|
|||
|---|---|---|---|
|
#18+
Радист? Так что с сыном-то было? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.09.2004, 11:45 |
|
||
|
|

start [/forum/topic.php?fid=60&msg=32676350&tid=2168922]: |
0ms |
get settings: |
9ms |
get forum list: |
15ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
42ms |
get topic data: |
9ms |
get forum data: |
2ms |
get page messages: |
74ms |
get tp. blocked users: |
1ms |
| others: | 222ms |
| total: | 380ms |

| 0 / 0 |
