执行select * from 表 where 条件语句后,判断query1.IsEmpty若为false则成功找到符合条件的记录,若query1.IsEmpty为true则未找到符合条件的记录。
if Query1.Eof And Query1.Bof then//没有找到记录 else//找到记录
以上方法都不错,我常用halfdream的方法
RecordCount不是很行 最好用ISEMPTY
怎么会呢,recordcount很好用啊!
在本地数据库,用Recordcount的确好用,但是在远端数据库就不灵了。 with query1 do begin close; sql.clear; sql.add('select count(*) from table1 where ....'); open; end;if query1.fields[0].Asinteger>0 then begin messagedlg('找到了'); end else begin messagedlg('他妈的,又没有找到!'); end;
else//找到记录
最好用ISEMPTY
with query1 do
begin
close;
sql.clear;
sql.add('select count(*) from table1 where ....');
open;
end;if query1.fields[0].Asinteger>0 then
begin
messagedlg('找到了');
end
else
begin
messagedlg('他妈的,又没有找到!');
end;