Connection error check

lubostlubost Member Posts: 627
edited 2008-06-26 in SQL General
Hi guys,
I have a question regarding connection check. We use ADO connection to database outside NAV and we sometimes reached error (timeout) during connection. Is it possible to check connection (via C/AL code) without raising an error?

Thanks for your responses.

Comments

  • BgestelBgestel Member Posts: 136
    one solution is to put the entire thing in the run trigger of a codeunit

    and then use the

    IF not codeunit.run then
    catchederror := getlasterrortext;

    now the error wil not be thrown to the screen.
    **********************
    ** SI ** Bert Van Gestel **
    **********************
  • kinekine Member Posts: 12,562
    Bgestel wrote:
    one solution is to put the entire thing in the run trigger of a codeunit

    and then use the

    IF not codeunit.run then
    catchederror := getlasterrortext;

    now the error wil not be thrown to the screen.

    Working only for NAV 5.00+... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • lubostlubost Member Posts: 627
    It's OK, but when I try to connect via ADO to database, Automation raises error. How catch this error.
  • kinekine Member Posts: 12,562
    The if codeunit.run then... is only way how to prevent displaying the error. Or you need to run it under NAS, but it will just write it into event log but you will be not able to "catch" it. Or you can use the Nav Timer automation because it has OnError trigger (but still you need to use the if codeunit.run then... construct to prevent displaying the error).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.