5
57605993
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
var
N:string;
begin
N:=trim(edit1.Text);
case radiogroup1.ItemIndex of
0:
with query1 do
begin
sql.Clear;
sql.Add('select empno,firstname');
sql.Add('from employee');
sql.Add('where firstname like :N1');
params[0].AsString:=N+'%';
open;
end;
1: with query1 do
begin
sql.Clear;
sql.Add('select empno,firstname');
sql.Add('from employee');
sql.Add('where firstname like :N1');
params[0].AsString:='%'+N;
open;
end;
2: with query1 do
begin
sql.Clear;
sql.Add('select empno,firstname');
sql.Add('from employee');
sql.Add('where firstname like :N1');
params[0].AsString:='%'+N+'%';
open;
end;
end;
按照书上所写
0: 是查询某字符(串)开头的记录;
1:是查询某字符(串)结尾的记录;
2:是查询包含某字符(串)的记录;
运行以后,后面两种方式都可以查到,第一个查以字符串开头的记录怎么都查不到,26个字母都试遍。。。我看代码都差不多。。找不到原因;
var
N:string;
begin
N:=trim(edit1.Text);
case radiogroup1.ItemIndex of
0:
with query1 do
begin
sql.Clear;
sql.Add('select empno,firstname');
sql.Add('from employee');
sql.Add('where firstname like :N1');
params[0].AsString:=N+'%';
open;
end;
1: with query1 do
begin
sql.Clear;
sql.Add('select empno,firstname');
sql.Add('from employee');
sql.Add('where firstname like :N1');
params[0].AsString:='%'+N;
open;
end;
2: with query1 do
begin
sql.Clear;
sql.Add('select empno,firstname');
sql.Add('from employee');
sql.Add('where firstname like :N1');
params[0].AsString:='%'+N+'%';
open;
end;
end;
按照书上所写
0: 是查询某字符(串)开头的记录;
1:是查询某字符(串)结尾的记录;
2:是查询包含某字符(串)的记录;
运行以后,后面两种方式都可以查到,第一个查以字符串开头的记录怎么都查不到,26个字母都试遍。。。我看代码都差不多。。找不到原因;