我用adotable或adoquery连接数据库更新记录时,老出错,更新到一定数据时就出错,提示大概如下:"key  column....",程序没有语法错误,如下:while not adotable.eof do 
begin
adotable.edit
adotable.fieldbyname('字段').asstring:='';
adotable.post;
adotable.next
end

解决方案 »

  1.   

    最好用字段对象来修改字段的值while not adotable.eof do 
    begin
    adotable.edit
    adotableName.Value := '';   // 比如字段对象的名称为 adotableName
    adotable.post;
    adotable.next
    end建立字段对象的方法:DataSet控件(就是这里的adotable)上点右键,"Fields Editer",再"Add Fields" 
      

  2.   

    可是用adotable或是adoquery都是动态连接的呀,不能事先对表的字段进行操作呀!
      

  3.   

    错误是:“key column information is insufficient or incorrect .too many rows were affected by update”,请问是怎么回事,不是字段不能为空,我每都更新为"11"
      

  4.   

    //加上下面一句话试试///
    adotable.first
    ////
    while not adotable.eof do 
    begin
    adotable.edit
    adotable.fieldbyname('字段').asstring:='';
    adotable.post;
    adotable.next
    end
      

  5.   

    adoquery的记录上下移动要用什么事件
      

  6.   

    :“key column information is insufficient or incorrect .too many rows were affected by update”
    多行被更新了,是不是你更新的这一个字段不能有重复的值?
      

  7.   

    第一,你的表有没有主键,这个问题很关键。
    第二,检查主键或唯一索引是否有冲突。
    优化一些语句
     adotable.disanblecontrol;
    try
    while not adotable.eof do 
    begin
     adotable.edit
     adotable.fieldbyname('字段').asstring:='';
     adotable.next
    end;
    if adotable.STATE IN [dsEdit] then
      adotable.POST;
    finally
      adotable.Eanblecontrol; 
    end;
    还是建议你将adotable改换为TADODATASET
      

  8.   

    while not adotable.eof do 
    begin
    adotable.edit
    adotable.fieldbyname('字段').asstring:='';
    adotable.post;
    adotable.next
    end
    問題出在您每次edit之後post,這樣每次post之後,當前紀錄指針又為第一條紀錄,所以建議采用
    樓上HZ_ZMD的方法
      

  9.   

    KEY:应该是数据库中的键
    不能为空