ServerName and DataBase name

HanenHanen Member Posts: 281
Hi,
i need to retrieve the name of the current server and the connected database name using C/AL.
thnx
Regards

Hanen TALBI

Comments

  • SavatageSavatage Member Posts: 7,142
    http://www.mibuso.com/howtoinfo.asp?FileID=2

    Did you search the forum for Servername?
    search.php

    Also searching for CONTEXTURL (select message text only) will provide multiple posts.
  • garakgarak Member Posts: 3,263
    viewtopic.php?f=5&t=27548

    For the future. first use the search function ;-)

    Regards and welcome
    Do you make it right, it works too!
  • HanenHanen Member Posts: 281
    Hi,
    thnx garak for your reply, this code retrieve the server and database name :

    Context := CONTEXTURL;
    ServerName := COPYSTR(Context,STRPOS(Context,'servername=')+11); // Delete the "prefix"
    ServerName := DELSTR(ServerName,STRPOS(ServerName,'&')); // Delete trailing p.
    DatabaseName := COPYSTR(Context,STRPOS(Context,'database=')+9); // -do-
    DatabaseName := DELSTR(DatabaseName,STRPOS(DatabaseName,'&')); // -do-
    Regards

    Hanen TALBI
  • garakgarak Member Posts: 3,263
    you're welcome
    Do you make it right, it works too!
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV Tips & Tricks' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.