Connect to database

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
AndreyZ

Re: Connect to database

Post by AndreyZ » Wed 04 Jul 2012 12:09

It's good to see that you've found a solution. If any other questions come up, please contact us.

ralfiii
Posts: 25
Joined: Wed 16 Mar 2011 09:25

Re: Connect to database

Post by ralfiii » Thu 12 Jul 2012 11:49

Hmmm?

Where do you get the ErrorCode-parameter from?
I'd like to determine if the target path was the problem or the server name and parsing the error message doesn't seem wise in a multi-language environment ;)

Thanks!
marsheng wrote:This seems to work

Code: Select all

   try
     MyConnection1.Connected:=True;
    except
     on E: EMyError do begin
      if e.ErrorCode = 1045 then
        ShowMessage('Invalid Server Address or Password')
      ...
      end;
     else
      ShowMessage('Unknown error');
  end;
end;

AndreyZ

Re: Connect to database

Post by AndreyZ » Thu 12 Jul 2012 14:02

The EMyError.ErrorCode property determines the error code returned by the server. You can find more information about MySQL error codes here:
http://dev.mysql.com/doc/refman//5.5/en ... dling.html
http://dev.mysql.com/doc/refman//5.5/en ... erver.html
http://dev.mysql.com/doc/refman//5.5/en ... lient.html

ralfiii
Posts: 25
Joined: Wed 16 Mar 2011 09:25

Re: Connect to database

Post by ralfiii » Thu 12 Jul 2012 14:11

AndreyZ wrote:The EMyError.ErrorCode property determines the error code returned by the server. You can find more information about MySQL error codes here:
http://dev.mysql.com/doc/refman//5.5/en ... dling.html
...
That's fine, but when I use IBDac and Delphi, there is no EMyError - classtype. And the TException-class doesn't provide this property.

AndreyZ

Re: Connect to database

Post by AndreyZ » Thu 12 Jul 2012 14:43

Every DAC has its own exception class. In IBDAC, you can use the EIBCError class that has the ErrorCode property. For more information about the EMyError and EIBCError classes, please refer to the MyDAC and IBDAC documentation.

marsheng
Posts: 62
Joined: Thu 10 May 2012 10:51

Re: Connect to database

Post by marsheng » Thu 12 Jul 2012 21:24

I basically created an error and found the message and then wrote the code.

A bit simpler than wading through piles of guff on the web.

I have just been on a seminar with DR Rob Adams, author of IF I BUILD IT WILL THEY COME.
Every programmer should attend his lecture or read his book.
We do things backwards. We should be asking people what they want rather than telling them what they need. Life would be so much simpler.

Have you wondered why Delphi after 10+ years in the field still does not have a numeric input component.

That's enough waffle for today.

Post Reply