如何修改dbgrid里的数据啊

解决方案 »

  1.   

    在编辑前测试数据集状态,大概如下,不在编辑状态的话,先进入编辑状态
    if table1.status<>'edit' then
      table1.edit;
      

  2.   

    你代码问题,修改时adoquery1.Edit;
    adoquery1.FieldByName('myname').AsString := '中国';
    adoquery1.Post;
      

  3.   

    不在修改或插入状态下 进行编辑货插入操作  table1.edit; or table1.insert;  table1.state=dsedit,table1.state=dsinsert
      

  4.   

    判断状态后再保存。
    if adoquery1.state in [dsEdit, dsInsert] then
      adoquery1.post;