Home > Back-end >  Couldn't access fuzzy query like why query, could you tell me where is wrong?
Couldn't access fuzzy query like why query, could you tell me where is wrong?

Time:10-08

Procedure TForm8. Button4Click (Sender: TObject);
The begin
With ADOQuery2 do
The begin
The close;
SQL. The Clear;
SQL. The Add (' Select * from insp where a, b, c, d like a '+' ' ' '+' % '+ Trim (edit1. Text) +' % '+' ' ' ');
The open;
end;
end;

Note: I am using ADO to connect the access database,
Couldn't access fuzzy query like why query, could you tell me where is wrong? Please answer!

CodePudding user response:

 Add (' Select * from insp where d like '+ Quotedstr (' %' + Trim (edit1. Text) + '%')); 

CodePudding user response:

Select * from insp where a like or the like, like like b or c or d,,
Where a, b, c, d like you too

CodePudding user response:

Method still doesn't work on the second floor, click fuzzy query, or the whole of the show, did not move, why?

CodePudding user response:

What I said is not on the first floor, wrong floor above,

CodePudding user response:

The solution?

CodePudding user response:

reference 3 floor response:
method still doesn't work on the second floor, click the fuzzy query, or the whole of the show, did not move, why?

Try to put the ACCESS

CodePudding user response:

In the access use like not to & amp; The & amp; To *.
 
Add (' Select * from insp where d like '+ Quotedstr (' *' + Trim (edit1. Text) + '*'));

CodePudding user response:

Select * from insp where a like 'study % %'
Simulation in the ACCESS query there is no problem,

But have a problem in Delphi, Delphi display red below four errors,
Procedure TForm8. Button4Click (Sender: TObject);
The begin
With ADOQuery2 do
The begin
The close;
SQL. The Clear;
SQL. Add (' Select * from insp where a like 'study % %');
Prepared;
The open;
end;
end;

CodePudding user response:

SQL. The Add (' Select * from insp where like 'a' study % % '");

CodePudding user response:

But you have to replace with * %
SQL. The Add (' Select * from insp where like 'a' study * * ");

ACCESS documents with a statement like this:
Please note that the ANSI SQL wildcards (%) and (_) in Microsoft only? Jet 4 X version and Microsoft OLE DB Provider for Jet is effective, if used in Microsoft Access or DAO, so they are seen as text,

CodePudding user response:

Upstairs, the following two although not display an error, but after click on the button, don't move, or all of the records in that, why?
Procedure TForm8. Button4Click (Sender: TObject);
The begin
With ADOQuery2 do
The begin
The close;
SQL. The Clear;
SQL. The Add (' Select * from insp where like 'a' study % % '");
Prepared;
The open;
end;
end;

Procedure TForm8. Button4Click (Sender: TObject);
The begin
With ADOQuery2 do
The begin
The close;
SQL. The Clear;
SQL. The Add (' Select * from insp where like 'a' study * * ");
Prepared;
The open;
end;
end;

CodePudding user response:

Prepared; This can not;

Open your access and table, lines contrast to see, what are not eligible to record
In addition, the record shows that there DBGrid? Associated with ADOQuery2?

LZ in our IQ test, appraisal end...

CodePudding user response:

Access can query, but not in Delphi dbgrid,

Adquery2 in SQL TStrings I fill in the: select * from insp
Double-click the adquery2, field all chose
The parameters of Tparameters I didn't move

CodePudding user response:

refer to 12th floor response:
Prepared; This can not;

Open your access and table, lines contrast to see, what are not eligible to record
In addition, the record shows that there DBGrid? Associated with ADOQuery2?

LZ in our IQ test, appraisal end...




Select * from insp where a like 'study % %'
This is can query in the access,

CodePudding user response:

http://download.csdn.net/detail/veron_04/1644211

CodePudding user response:

Var a1, a: string;
A1:='%' + edit1. Text + '%';
A:='select * from table where the query fields like' ' '+ a1 + "' "';
Adoquery2. Close;
Adoquery2. SQL. The clear;
Adoquery2. SQL. The add (a);
Adoquery2. Open;


CodePudding user response:

Access is different from the wildcard in SQL server, you replace with * % with respect to OK

CodePudding user response:

Feel the statement has been an error
  • Related