数据表的结构
 picID   int
 name    char(20)
 height  int
 width   int//将数据加入添加入dbgride缓冲
procedure Tfrm_setPicture.btn_addClick(Sender: TObject);
begin
  btn_add.Enabled := false;
  query1.RecNo := query1.recordcount;
  query1.RequestLive := true;
  query1.InsertRecord([strtoint(edt_picid.text),edt_picname.text,strtoint(edt_picheight.text),strtoint(edt_picwidth.text)]);
  query1.RequestLive := false;
  btn_commit.Enabled := true;
  btn_add.Enabled := false;
  imgpic.Picture := nil;
  edt_picid.Text := '';
  edt_picname.Text := '';
  edt_picwidth.Text := '';
  edt_picheight.Text := '';
end;// 将数据提交到后端库
procedure Tfrm_setPicture.btn_commitClick(Sender: TObject);
begin
  dm.Database.StartTransaction;
  try
    query1.ApplyUpdates;
    query1.CommitUpdates;
    dm.Database.Commit;
  except
    application.MessageBox('处理数据有误,请重新添加','提示',mb_iconerror+mb_ok);
    query1.CancelUpdates;
    dm.Database.Rollback;
  end;
end;
   为什么提交时,总是提示PicId的类型出错,不能提交

解决方案 »

  1.   

    picID是不是自增型字段?
    那样是不能插入值的。
      

  2.   

    不用strtoint也不行picID不是自增型字段现在问题是提交后,只有picID字段的值提交进去。
    而其它的几个字段却没有提交成功,但是也不报错。
      

  3.   

    如果用SQL语句直接添加,会有问题吗?
      

  4.   

    在query1.RequestLive := true;前加入
    query1.cachedupdate:=true;
      

  5.   

    to 西域浪子
    query1.RequestLive:=true;
    我添加的有to 虚竹
    我在query的属性
    已经设置cachedupdate 为真了大家还有别的解决办法没有
      

  6.   

    忘了告诉大家
    我还同时用了一个
    updatequery
      

  7.   

    可能是updatesql中的insertsql中只让插入picid
    试试重新设置一下updatesql属性