for i:=1 to 99 do
begin
queryid.sql.text:='select id from table where id = hao'''+inttostr(i)+'''';
queryid.Open;
if queryid.IsEmtyp then
begin
dbid.text:='of'+String(i);
exit;
end;
end;
begin
queryid.sql.text:='select id from table where id = hao'''+inttostr(i)+'''';
queryid.Open;
if queryid.IsEmtyp then
begin
dbid.text:='of'+String(i);
exit;
end;
end;
query1.sql.text := 'select id from table order by id';
query1.open;if not isempty then
begin
id := query1.fieldbyname('id').asstring;
dbid.text := 'of' + inttostr(strtoint(id) + 1);
end;
query1.open;id:=Query1.FieldByName('id').AsInteger+1;
dbid.text:=IntToStr(id);
但是order后是2,
31,
4,
53,
6
好象不大对哦 。