Permissions and Messages from MyDac

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
gohjoe
Posts: 7
Joined: Thu 17 Jan 2008 14:35

Permissions and Messages from MyDac

Post by gohjoe » Sun 27 Jan 2008 20:12

With MySql, we can grant certain users certain permissions on a database or table or field. If a user tries to do something he is not supposed to do, how can we get the MyDac components to get these permission messages back to Delphi and our programs to present them to the users.
Can you give me coding examples?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 28 Jan 2008 13:08

You can catch EMyError exceptions in try..except statements. Use EMyError.ErrorCode to know the error code.
For more information about the error code read the MySQL Reference Manual.
For example:

Code: Select all

  try
    MyTable.Post;
  except
    on E: EMyError do
      if E.ErrorCode = 1142 then  //ER_TABLEACCESS_DENIED_ERROR
        ShowMessage('Access to a server object denied.'#13#10 + 'Message: ' + E.Message)
      else
        raise;
  end;

Post Reply