Options

Connected to the server or working local

ngebhardngebhard Member Posts: 127
Hi everybody,

does anybody know how to find out if the database I'm working in is connected to the server or if I'm working local? I mean the information shown in the connection-tab using the path "file>database>information". I need to know that in a procedure to decide which function should be used and I can't find this information in any of the tables given, even not if search the "invisble tables" using a form.

Any ideas?

Thanks a lot.
Best regards,
N. Gebhard
ProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt

Comments

  • Options
    Tommy_SchouTommy_Schou Member Posts: 117
    ngebhard wrote:
    Hi everybody,

    does anybody know how to find out if the database I'm working in is connected to the server or if I'm working local? I mean the information shown in the connection-tab using the path "file>database>information". I need to know that in a procedure to decide which function should be used and I can't find this information in any of the tables given, even not if search the "invisble tables" using a form.

    I tried as you have to look for a function or something similar that would reveal that information. Didn't have any luck.

    Have you considered alternative methods for determining this? Ie. to check the name of the current database? If you are lucky then the database you are running locally vs. the one the server runs are not located on the same drive or in the same folder. They may even be named differently. Thus you could hardcode (slaps my own wrist) the name of the server's database and check the name at runtime. This info is located in the virtual table "session" btw.
    Best regards
    Tommy
  • Options
    elToritoelTorito Member Posts: 191
    Hi.

    I make so that I rename the Company in my Local Databases.
    So I can see directly/quickly if i am work on the Server or on a local Database.

    Navision makes Temporary Files in a Path, you can try the option that your Server Database put this Files in a defined Path and for Local Databases Configure so that Navision put the Files in another Temp Path.
    So you can see every Time if Temporary Files in a Path that you a working on it.
    (Oo)=*=(oO)
  • Options
    fbfb Member Posts: 246
    See the following how-to: http://www.mibuso.com/howtoinfo.asp?FileID=2

    Note especially that
    The function fctGetServerName returns [... blank] when connected to a local database
  • Options
    kinekine Member Posts: 12,562
    Some other solution: if you know path and file name, if you are working localy, you find this file, if you are working on server (on another PC) you cannot find this file on local PC (if same path and file is not existing on you local PC).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    RobertMoRobertMo Member Posts: 484
    Try CONTEXTURL.
    In my function on main menu I parsed the result of contexturl to display this msg:

    Microsoft Navision Attain
    CONTEXTURL:

    [url=navision://client/run]navision://client/run[/url]
    servername=sql1
    database=KZDR
    company=Cronus d.o.o.
    servertype=MSSQL
    OK
    ltContextURL := CONTEXTURL;
    liPos := STRPOS(ltContextURL, '\');
    WHILE liPos > 0 DO BEGIN
      ltContextURL := DELSTR(ltContextURL, liPos, 1);
      ltContextURL := INSSTR(ltContextURL, '%1', liPos);
      liPos := STRPOS(ltContextURL, '\');
    END;
    ltContextURL := CONVERTSTR(ltContextURL, '&?', '\\');
    MESSAGE('CONTEXTURL:\\'+ltContextURL,'\');
    
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    RobertMoRobertMo Member Posts: 484
    Actually here is a function I use on different version & servers:
    PROCEDURE ADGetServerDBInfo@1000000000(ltWhatToGet@1000000003 : Text[30]) ltReturnName : Text[255];
        VAR
          ltTemp@1000000004 : Text[250];
          liPos@1000000005 : Integer;
          lrSession@1000000000 : Record 2000000009;
        BEGIN
          // ADGetServerDBInfo
          //-AD.RM
          { Usage:
          Call ADGetServerDBInfo('servername=') to Get Server Name
          Call ADGetServerDBInfo('servertype=') to Get Server Type
          Call ADGetServerDBInfo('database=') to Get Database Name
          Call ADGetServerDBInfo('company=') to Get Company Name
          }
          ltReturnName := '<unknown>';
          ltTemp := CONTEXTURL;
          liPos := STRPOS(ltTemp, ltWhatToGet);
          IF liPos > 0 THEN BEGIN
            ltTemp := COPYSTR(ltTemp, liPos + STRLEN(ltWhatToGet));
            liPos := STRPOS(ltTemp, '&');
            IF liPos = 0 THEN liPos := 999;
            ltReturnName := COPYSTR(ltTemp, 1, liPos - 1);
          END ELSE BEGIN
            CASE ltWhatToGet OF
              'servername=' : ltReturnName := '<local>';
              'database=' : BEGIN
                 lrSession.SETRANGE(lrSession."My session", TRUE);
                 IF lrSession.FIND('-') THEN ltReturnName := lrSession."Database Name";
              END;
            END;
          END;
          EXIT(ltReturnName);
          //+AD.RM
        END;
    

    Main Manu - OnOpen I call:
    tServerName := ADGetServerDBInfo('servername=');
    tServerType := ADGetServerDBInfo('servertype=');
    tDatabaseName := ADGetServerDBInfo('database=');

    ...to show data on 3 controls. Of course you can put a function call directly in source expression
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    ngebhardngebhard Member Posts: 127
    Thanks a lot for your help!
    I am able to solve the problem now...
    ProTAKT Projekte & Business Software AG
    Microsoft Dynamics NAV Partner
    Bad Nauheim, Germany
    http://www.protakt.de
    http://twitter.com/protakt
Sign In or Register to comment.