Recent

Author Topic: search data - sqlquery  (Read 13326 times)

abmservice

  • Jr. Member
  • **
  • Posts: 69
search data - sqlquery
« on: December 03, 2009, 09:49:17 pm »
how to search data using 'Sqlquery' not an exact search only approximate?

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: search data - sqlquery
« Reply #1 on: December 04, 2009, 05:08:58 am »

Luciano

  • New Member
  • *
  • Posts: 19
Re: search data - sqlquery
« Reply #2 on: December 04, 2009, 07:10:38 pm »
You need a beginner details? :)

abmservice

  • Jr. Member
  • **
  • Posts: 69
Re: search data - sqlquery
« Reply #3 on: December 04, 2009, 07:44:17 pm »
how to search data using 'Sqlquery' not an exact search only approximate?
do not want to restrict the visibility of records just want to pass on a search ustawiał record
so as table.findnearest  (delphi) HELP ME!!
« Last Edit: December 04, 2009, 08:01:10 pm by abmservice »

Luciano

  • New Member
  • *
  • Posts: 19
Re: search data - sqlquery
« Reply #4 on: December 04, 2009, 08:00:26 pm »
Well,
if i'm understand (approximate), the follow:

in truth, i'm use Zeos (recomended), but it's have functional of
sqlquery too.

with sqlquery_name do begin
  sql.clear;
  sql.text := 'select * from table where your_field like :your_field';
  active := false;
  paramByName('your_field').asString := edit1.text + '%';
  active := false;
end;


If you need found the expression in center of string use too the
'%' before the edit1.text.

Only it.

Luciano

  • New Member
  • *
  • Posts: 19
Re: search data - sqlquery
« Reply #5 on: December 04, 2009, 08:05:40 pm »
I'm don't see your description 'table.findNearest',
i'm believe that are like it, or too table.goToNearest.

:)

abmservice

  • Jr. Member
  • **
  • Posts: 69
Re: search data - sqlquery
« Reply #6 on: December 04, 2009, 08:11:35 pm »
I use the sql like this but I will limit the number of visible results, or can I use sqlquery.locate but looks just exactly: (
I use the basic components of Lazarus. ibconnection and Sqlquery
« Last Edit: December 04, 2009, 08:14:40 pm by abmservice »

Luciano

  • New Member
  • *
  • Posts: 19
Re: search data - sqlquery
« Reply #7 on: December 04, 2009, 08:20:12 pm »
As far as I use, it restricts the visibility of the data (I have not spent this limit). But I think it is acceptable. If you consider that the User will delete the text of the TEdit to consult.

Luciano

  • New Member
  • *
  • Posts: 19
Re: search data - sqlquery
« Reply #8 on: December 04, 2009, 08:52:31 pm »
I mean the one with the TEdit OnChange event for the query.

DougNettleton

  • Jr. Member
  • **
  • Posts: 84
Re: search data - sqlquery
« Reply #9 on: December 04, 2009, 10:23:11 pm »
Like someone said above, I use Zeos, but the "locate" method is available for TSQLQuery as well as ZQuery.

Since you don't want to "restrict view" of the data, I guess, like me, you want to move through the data in response to user interaction.

I do the following:

  if EmployerNumberItem.Checked then
    EmployerQry.Locate('emprnumb',Edit1.Text, [loPartialKey])
  else
    EmployerQry.Locate('emprname',Edit1.Text, [loCaseInsensitive,
      loPartialKey]);

My field Edit1.Text has either a numeric string - all or part of an "Employer Number" or a character string - all or part of an "Employer Name".

HTH,

Doug

abmservice

  • Jr. Member
  • **
  • Posts: 69
Re: search data - sqlquery
« Reply #10 on: December 05, 2009, 05:41:30 am »
when you want to use locate ( 'code', edit1.text [loCaseInsensitive, loPartialKey]) have a compiler error "identifier not found'loCaseInsensitive's what these instructions mean loCaseInsensitive, loPartialKey ??????

DougNettleton

  • Jr. Member
  • **
  • Posts: 84
Re: search data - sqlquery
« Reply #11 on: December 07, 2009, 05:09:34 pm »
I guess you've got your "database stuff" in another unit.  Just add, "DB" to the uses clause.  the following are there ...

  TLocateOption = (loCaseInsensitive, loPartialKey);
  TLocateOptions = set of TLocateOption;

loCaseInsensitive means:

'AAAA' is the same as 'AaAa' or 'aaaa' etc.

loPartialKey means:

find the first which matches however much of the value you pass. 

So if you have a file with people's names

Doe, John
Gibson, Henry
Smith, Mary
Smith, Yolanda

and you try to locate "Smith", it will find "Smith, Mary".  If you don't use loPartialKey, it won't find either of the Smiths.

If you use both loCaseInsensitive and loPartialKey and you try to locate "SMITH, y", it will find "Smith, Yolanda"

HTH,

Doug

 

TinyPortal © 2005-2018