Finding the Server Name and Database Name

darrenc
Member Posts: 16
Does anyone know how to retrieve the server name and database name in code? I need to display this on a report.
Thanks
Darren
Thanks
Darren
0
Comments
-
You can use this How To to retrieve the servername: How To retrieve servername and servertype?No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0
-
Thanks Luc. The CONTEXTURL has the database in it also. I should be able to parse it out.0
-
If you are using SQL-server then you can use the virtual table "Server" to retrieve the servername, and the virtual table "Session" to retrieve the databasename (but this is a performance killer).0
-
-
On most DBs I have following function:
PROCEDURE ADGetServerDBInfo@1000000001(ltWhatToGet@1000000003 : Text[30]) ltReturnName : Text[250]; 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;
I have this function on Main Menu with 3 text variables:tServerName Text250 tServerType Text250 tDatabaseName Text250
...that I use them as source Expression for 3 barely visible fields at bottom. So I always know on which DB I'm working...
It looks like...
http://freeweb.siol.net/saromo/ADGetServerDBInfo.jpg®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions