比如,我有一非空字段内没有填写数据,我希望table在onposterror事件内获得错误号

解决方案 »

  1.   

    一般来说提交的sql语言delphi不对其进行语法匹配的
    可以用事务
    if 错误 rollback 
    else commit
      

  2.   

    //根据原生错误码显示错误提示
        for I := 0 to AParam.AConnection.Errors.Count - 1 do
        begin
          case AParam.AConnection.Errors[I].NativeError of
            547  : begin
                     if pos('insert',AParam.AConnection.Errors[I].Description) > 0 then
                     begin
                       //'外键约束insert,delete,update';
                       if sErrText <> '' then sErrText := sErrText + #13;
                       sErrText := sErrText + 's';
                     end
                     else
                     if pos('delete',AParam.AConnection.Errors[I].Description) > 0 then
                     begin
                       if sErrText <> '' then sErrText := sErrText + #13;
                       sErrText := sErrText + 's';
                     end
                     else
                     if pos('update',AParam.AConnection.Errors[I].Description) > 0 then
                     begin
                       if sErrText <> '' then sErrText := sErrText + #13;
                       sErrText := sErrText + 's';
                     end;
                   end;//end of 547        945  : begin
                     if sErrText <> '' then sErrText := sErrText + #13;
                     sErrText := sErrText + '您的内存不足!';
                   end;//end of 945        4850 : begin
                     if sErrText <> '' then sErrText := sErrText + #13;
                     sErrText := sErrText + '数据库表被锁定!';
                   end;//end of 1204        2627 : begin
                     if sErrText <> '' then sErrText := sErrText + #13;
                     sErrText := sErrText + '输入的关键属性值已经存在!';
                   end;//end of 2627        7303 : begin
                     if sErrText <> '' then sErrText := sErrText + #13;
                     sErrText := sErrText + '网络初始化失败!请检查网络设置!';
                   end;//end of 7303        10024: begin
                     if sErrText <> '' then sErrText := sErrText + #13;
                     sErrText := sErrText + '网络连接超时!请检查网络设置!';
                   end;//end of 10024        else   begin
                     if
                   end;
          end;//end of case    end;//end of for
      

  3.   

    我现在用dbgrid连接一个ADOtable,在dbgrid内填写数据,但是我希望在必填字段为空时报错