SBX - Search With Button

SBX - Forum Post Title

database name and server name in c/al

Microsoft Dynamics NAV Forum

Franz Kalchmair asked a question on 30 Sep 2014 6:04 AM
My Badges

Question Status

Verified

hi,

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

br

Reply
Franz Kalchmair responded on 7 Oct 2014 3:03 PM
My Badges

hi mohana,

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

br

Reply
Franz Kalchmair responded on 12 Oct 2014 9:41 AM
My Badges

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.

Reply
Rene Brummel responded on 7 Aug 2018 2:10 AM

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";

Reply

SBX - Two Col Forum

SBX - Migrated JS