var
 i:integer;
begin
  i:=ADOQuery1.RecordCount;
   i:=i+1;
   with ADOQuery1 do
    begin
       append;
       fieldbyname('id').asinteger:=i;
       fieldbyname('danwei').asstring:='tstring';
       post;
    end;
end;

解决方案 »

  1.   

    //input corpnamedeclare @id int
    select @id = max(field_id) from table
    @id = @id + 1
    insert into table values (@id,@corpname)OK?
      

  2.   

    在SQL 2000中设计表时将序号的属性 indentity increament 设置为1
    declare @name //name 指单位
    INSERT INTO TABLE VALUES (@NAME)
    则插入一条记录序号自加1。
      

  3.   

    我用编写过程如下;因本人对SQL SERVER 的语法不很子解,请自己转化一下,主要在变量定义上有所不同。
    create or Replace procedure InsertTB(
    P_DWMC Char,--单位名称
    P_DWID OUT NUMBER
    ) as 
    v_DWID Number;--单位序号
    begin
      select NVL(max(DWID),0) into V_DWID from DW;
      V_DWID:=V_DWID+1;
      Insert Into DW
      Values(V_DWID,P_DWMC);
      COMMIT;
      P_DWID:=V_DWID;
    exception 
      when Others then  NULL;
    end;
      

  4.   

    补充,以上过程在 ORACLE 8.0.5上通过。
      

  5.   

    to tanfo2002(tanfo)
       是不是标识设为“是”,然后在标识递增量设为“1”呢?