见下面代码
procedure ....
var
tmp1 : TQuery;
begin
...
tmp1:=TQuery.Creat(self);
tmp1.Close;
tmp1.SQL.Clear;
tmp1.SQL.Add('select * from 学生 where 性别=''男'''); //'学生'表中有记录
tmp1.Open;
showmessage('姓名='+tmp1.FieldByName('姓名').AsString);
//显示不出tmp1.FieldByName('姓名').AsString的内容啊?
...
end;
procedure ....
var
tmp1 : TQuery;
begin
...
tmp1:=TQuery.Creat(self);
tmp1.Close;
tmp1.SQL.Clear;
tmp1.SQL.Add('select * from 学生 where 性别=''男'''); //'学生'表中有记录
tmp1.Open;
showmessage('姓名='+tmp1.FieldByName('姓名').AsString);
//显示不出tmp1.FieldByName('姓名').AsString的内容啊?
...
end;
var
tmp1 : TQuery;
begin
...
tmp1:=TQuery.Create(self); //少了个e
tmp1.Close;
tmp1.SQL.Clear;
tmp1.SQL.Add('select 姓名 from 学生 where 性别=''男'''); //'学生'表中有记录不要用*
tmp1.Open;
showmessage('姓名='+tmp1.FieldByName('姓名').AsString);
//显示不出tmp1.FieldByName('姓名').AsString的内容啊?
...
end;
对DELPHI的控制能力不行,就不要说DELPHI不行。注意字段的空格,有些记录的前后,特别是后,要是有空格的话,比如说‘男’和‘男 ’是不相等
的,调试一下你的后台看看。 要么就是你的后台没有满足条件的记录。
procedure ....
var
tmp1 : TQuery;
begin
...
tmp1:=TQuery.Create(self); //少了个e
tmp1.Close;
tmp1.SQL.Clear;
tmp1.SQL.Add('select 姓名 from 学生 where 性别 like ''%男%'''); //'学生'表中有记录不要用*
tmp1.Open;
showmessage('姓名='+tmp1.FieldByName('姓名').AsString);
//显示不出tmp1.FieldByName('姓名').AsString的内容啊?
...
end;