Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

database name and server name in c/al

Posted on by 32,675

hi,

how can i get the current database name and server name in my c/al code?

br

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: database name and server name in c/al

    For Dynamics NAV and Al development you can use the Active Session tabel. See function GetDatabaseIndicatorText in table 79:

    ActiveSession.SETRANGE("Server Instance ID",SERVICEINSTANCEID);

    ActiveSession.SETRANGE("Session ID",SESSIONID);

    ActiveSession.FINDFIRST;

    Text := ActiveSession."Database Name" + ' - ' + ActiveSession."Server Computer Name";

  • keoma Profile Picture
    keoma 32,675 on at
    RE: database name and server name in c/al

    hi,

    unfortunately does not work for nav 2013.

    it's done by the WSH (Windows Scripting Host).

    variables:

    - "wshNetworkInfo", Type: Automation, Subtype: 'Windows Script Host Object Model'.WshNetwork

    - "compName", Type: Text

    Code sample:

    CREATE(wshNetworkInfo);

    compName := wshNetworkInfo.ComputerName;

    CLEAR(wshNetworkInfo);

    properties of class WshNetwork:

    - UserDomain

    - UserName

    - UserProfile

    - ComputerName

    - Organization

    - Site

    for nav 5.0 function ENVIRON('COMPUTERNAME') works fine.

  • keoma Profile Picture
    keoma 32,675 on at
    RE: database name and server name in c/al

    hi mohana,

    tables 2000000047 to get server and 2000000048 to get the Database name is the answer. thx.

    br

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,133 Super User 2024 Season 2 on at
    RE: database name and server name in c/al

    try these posts

    http://www.dynamics.is/?p=541

    www.mibuso.com/.../viewtopic.php

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,232 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,064 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans