convert ADO to UNIDAC

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
caksul
Posts: 8
Joined: Fri 06 Apr 2012 15:09
Location: Indonesia

convert ADO to UNIDAC

Post by caksul » Fri 06 Apr 2012 15:15

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

AndreyZ

Post by AndreyZ » Mon 09 Apr 2012 12:51

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.

caksul
Posts: 8
Joined: Fri 06 Apr 2012 15:09
Location: Indonesia

Post by caksul » Tue 10 Apr 2012 01:29

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.

AndreyZ

Post by AndreyZ » Tue 10 Apr 2012 07:19

Feel free to contact us if you have any further questions about UniDAC.

caksul
Posts: 8
Joined: Fri 06 Apr 2012 15:09
Location: Indonesia

Post by caksul » Tue 17 Apr 2012 13:19

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.

AndreyZ

Post by AndreyZ » Tue 17 Apr 2012 14:07

I've answered you there.

Post Reply