with adoquery1 do
begin
close;
sql.clear;
sql.add('select * from scyb wheresid='12121');
open;
end;
if adoquery1.recordcount=0 then
begin
end;
此条语句如果scyb中有数据的话此则成功,如果scyb是个空表的话recordcount就总返回1,用select count(*) 语句,取count的返回值也不行,总是得1,不知道为什么?
begin
close;
sql.clear;
sql.add('select * from scyb wheresid='12121');
open;
end;
if adoquery1.recordcount=0 then
begin
end;
此条语句如果scyb中有数据的话此则成功,如果scyb是个空表的话recordcount就总返回1,用select count(*) 语句,取count的返回值也不行,总是得1,不知道为什么?
改为
if not (adoquery1.eof and adoquery1.bof) then
if adoquery1.recordcount>0 then 代表不为空
adoquery1.first ;
if adoquery1.recordcount=0 then
begin
end;或者if adoquery1.IsEmpty then
begin
end ;
if adoquery1.Fields.Fields[0].AsInteger > 0 then
begin
end ;
ShowMessage(FieldByName('k').AsString) ; // 新建一个表看看是不是 0
所以要想判断是否为空应该用:IsEmpty
if query1.IsEmpty then //如果为空
begin
//你要做的事情
end;
那就加个:adoQuery1.first;