Page 1 of 1

convert ADO to UNIDAC

Posted: Fri 06 Apr 2012 15:15
by caksul
I am coding with the ADO are:

qryCusType.post try;
except
on E: EDatabaseError do

if qryCusType.Connection.Errors [0]. NativeError = 2627 then begin / / Key violation (key already exists).
with editTypeName do begin Show; SetFocus; end;
raise (exception.create ('Type Name must be unique'));
end else if frmKaifa.ADOConnection1.Errors [0]. NativeError = 32 then raise (exception.create ('Unable to insert or update Customer Type ...' + # 13 + 'It has been changed or deleted since last retrieved') )
else raise;
end;

what if I use UNIDAC?

thanks

caksul

Posted: Mon 09 Apr 2012 12:51
by AndreyZ
Hello,

You can use the following code:

Code: Select all

procedure TMainForm.BitBtnClick(Sender: TObject);
var
  er: EMSError;
begin
  try
    UniQuery.Post;
  except
    on E: EUniError do begin
      er := EMSError(E.InnerError);
      if er.MSSQLErrorCode = 2627 then
        // your code
    end;
  end;
end;
Please note that to use the EMSError class, you should add the OLEDBAccessUni unit to the USES clause of your unit.

Posted: Tue 10 Apr 2012 01:29
by caksul
thanks
AndreyZ wrote:Hello,

You can use the following code:

Code: Select all

procedure TMainForm.BitBtnClick(Sender: TObject);
var
  er: EMSError;
begin
  try
    UniQuery.Post;
  except
    on E: EUniError do begin
      er := EMSError(E.InnerError);
      if er.MSSQLErrorCode = 2627 then
        // your code
    end;
  end;
end;
Please note that to use the EMSError class, you should add the OLEDBAccessUni unit to the USES clause of your unit.

Posted: Tue 10 Apr 2012 07:19
by AndreyZ
Feel free to contact us if you have any further questions about UniDAC.

Posted: Tue 17 Apr 2012 13:19
by caksul
thanks

http://www.devart.com/forums/viewtopic.php?t=23859
AndreyZ wrote:Feel free to contact us if you have any further questions about UniDAC.

Posted: Tue 17 Apr 2012 14:07
by AndreyZ
I've answered you there.