ab不用申请的, 因为'select count(*) as ab from shang where 语文>20'这句话中的
ab是字符串, 不是变量. 所以你的程序中根本没有用到ab这个变量.
你的程序可以这样:
begin
with query1 do
begin
close;
sql.clear;
sql.text:='select count(*) as ab from shang where 语文>20';
open;
end;
label1.caption :=FieldByName('ab').AsString;
begin
with query1 do
begin
close;
sql.clear;
sql.text:='select count(*) from shang where 语文>20';
open;
end;
label1.caption :=inttostr(Query1.fields[0].AsInteger);
var ab :integer;
begin
with query1 do
begin
close;
sql.clear;
sql.text:='select * from shang where 语文>20';
open;
end;
label1.caption :=inttostr(query1.RecordCount);//ab好象没有付值
zdg 我错在哪里?
var ab :integer;
begin
with query1 do
begin
close;
sql.clear;
sql.text:='select count(*) as ab from shang where 语文>20';
open;
end;
label1.caption :=inttostr(ab);//ab好象没有付值