SQL-Server Messages

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ASKtec
Posts: 11
Joined: Thu 29 Jan 2009 14:52

SQL-Server Messages

Post by ASKtec » Thu 30 Dec 2010 13:01

Hello,

is there a way to get the return message of a mySQL- and a MSSQL-Server after Execute if there is a failure in the statement?

For example the message "You have a syntax error near...".

Thank you for your help.

Kind regards
Andreas

AndreyZ

Post by AndreyZ » Thu 30 Dec 2010 15:03

Hello,

You can use this code:

Code: Select all

  try
    UniQuery.Open;
  except
    on E: EUniError do begin
      ShowMessage(E.Message);
    end; 
  end;

ASKtec
Posts: 11
Joined: Thu 29 Jan 2009 14:52

Post by ASKtec » Thu 30 Dec 2010 22:13

Thank you,

but what is with messages like:

"10 rows affected" ?

Is there a way to get those messages too?

DepSoft
Posts: 20
Joined: Tue 27 Jul 2010 03:01
Location: Western Australia

Post by DepSoft » Sun 02 Jan 2011 09:07

You can check the RowsAffected property of a query as follows (from help):

Returns the number of rows operated upon by the latest query execution.

Inspect RowsAffected to determine how many rows were updated or deleted by the last query operation. If no rows were updated or deleted, RowsAffected has a value of zero. RowsAffected will have a value of –1 if the execution of the SQL statement could not be executed due to an error condition. This latter situation would typically follow the raising of an exception.

Regards, Paul.

Post Reply