procedure TFrmShebeiIn.ComboBox9Exit(Sender: TObject);
var
  TmpAdodateset : TADODataSet;
begin
  if not CheckHaveClientBuMen(Trim(combobox9.text)) then
  begin
    if  Application.MessageBox('在客户系统没有此客户!' + #13#10 +
      '是否作为临时客户?','提示',MB_YESNO) = IDYES then
      begin
        TmpAdodateset := TADODataSet.Create(self);
        try
          TmpAdodateset.Connection := FrmShebeiMain.ADOConnection1;
          TmpAdodateset.Active := false;
          TmpAdodateset.CommandText := 'select 单位客户编号,单位客户名称 from 客户_单位客户信息表' + #13#10 +
          ' where 1=2';
          TmpAdodateset.Active := true;
          TmpAdodateset.Open;
          TmpAdodateset.FieldByName('单位客户编号').AsString := 'ls00000' ;
          TmpAdodateset.FieldByName('单位客户名称').AsString := Trim(combobox9.Text);
          TmpAdodateset.FieldByName('客户性质').AsInteger := 1;
          TmpAdodateset.Post;
          TmpAdodateset.Active := false;
        except
          TmpAdodateset.Active := false;
          TmpAdodateset.Free;
          Application.MessageBox('无法添加临时客户!','提示',MB_OK);
        end;
      end
    else
      begin
        combobox9.itemindex := -1;
        combobox9.text := '';
        Application.MessageBox('请先在客户系统中输入该单位信息', '提示', MB_OK);
      end
  end;
end;为什么上面老报错呀,大哥们帮小弟看看呀,

解决方案 »

  1.   

    ..
    ..
    else
          begin
            combobox9.itemindex := -1;
            combobox9.text := '';
            Application.MessageBox('请先在客户系统中输入该单位信息', '提示', MB_OK);
          end;<-------------------
      end;
      

  2.   

    不能插入,我在 TmpAdodateset.Active := true; 后加了一条,问题没有,
              TmpAdodateset.Open;
              TmpAdodateset.Append;<---------------
    但是报错说没有找到,TmpAdodateset.FieldByName('客户性质').AsInteger := 1; 客户性质这个字段,明明库里有这个字段呀,
      

  3.   

    ADOQuery.Close;
    ADOQuery.SQL.Add('Insert into tablename(field1, field2,..) values(值1, 值2, ...)');
    ADOQuery.ExecSQL;
      

  4.   

    TmpAdodateset.Active := true;
    TmpAdodateset.Open;你把这两句放一起干嘛?都是一个意思啊,只要用一句就可以了
      

  5.   

    to smiler007(笑一笑) 
     谢谢指点,马上改正;
    to  jianghd(天天) 
    你的方法很简单,很好!谢谢提供,
    今天下午结贴。