使用dbedit向数据库中增加数据时候:
执行到adotable1.post;时候报如下错误。请问是什么问题?
Project Project1.exe raised exception class EOleException with message '数据提供程序或其他服务返回E_FAIL状态。'.Process stopped. Use Step or Run to continue.if RzButton6.caption='添加'then
begin
adotable1.Last;
adotable1.append;
adotable1.Edit;
......
exit;
end;if RzButton6.caption='确定'then
begin
adotable1.Edit;
adotable1.Post;  //运行到这里出错
......
end;

解决方案 »

  1.   

    if RzButton6.caption='确定'then
    begin
    //adotable1.Edit;//去掉试试
    adotable1.Post;  //运行到这里出错
    ......
    end;
      

  2.   

    if RzButton6.caption='添加'then
    begin
    //adotable1.Last;append会自动在末条记录增一条空记录。
    adotable1.append;
    //adotable1.Edit;增加空记录后,自动会是编辑状态!
    ......
    //exit;把exit去掉吧!
    end;
    if RzButton6.caption='确定'then
    begin
    //adotable1.Edit;//这个也应该去掉
    adotable1.Post;  //运行到这里出错
    ......
    end;
      

  3.   

    with adotable1 do
    begin
        disablecontrols;
        if RzButton6.caption='添加'then
        begin
          adotable1.append;
        end;
        if RzButton6.caption='确定'then
        begin
           adotable1.Edit;
           //添加语句
           adotable1.Post;  //运行到这里出错
        end;
        enablecontrols;
    end;
      

  4.   

    不好意识上面的错了!
    看看这个
    with adotable1 do
    begin
        disablecontrols;
        if RzButton6.caption='添加'then
        begin
          append;//只是添加一条空记录,如果你的数据库定义了关键字而为空那就能出现错误
          //该处应该是添加空记录中各字段的值!
          post;
        end;
        if RzButton6.caption='确定'then
        begin
           Edit;
           //添加语句
           Post;  //运行到这里出错
        end;
        enablecontrols;
    end;
    这个你在试试!
      

  5.   

    好象不是这个的问题。我写了这样的测试程序执行到POST,还是出这个错误。
    procedure TForm2.RzButton6Click(Sender: TObject);
    begin
    with Adotable1 do
      begin
      adotable1.append;
      adotable1.fieldbyname('itemid').AsString := 'D01';
      adotable1.fieldbyname('itemdesc').AsString := 'test';
      adotable1.fieldbyname('itemvalue').asfloat := 29;
      if adotable1.state in [dsinsert,dsedit] then
      post;
      end;
      end;
    表是这样的。
    create table cjtab_Glcbfz (
    itemid char(3) not null, /*id*/
    itemdesc   char(40),        /*描述*/
    itemvalue numeric(8,2) default 0 /*管理成本分值*/
    )
      

  6.   

    算了,用query做就没问题了。