How to get server and database name from C/SIDE

zyyrafzyyraf Member Posts: 9
edited 2008-10-02 in NAV Tips & Tricks
Hi, what is a best way to get server address and database name of current connection from C/SIDE (database on SQL)?

I found that way:
//svr Record Server
//db Record Database

srv.FINDFIRST;
WHILE NOT srv."My Server" DO
  srv.NEXT;


dbs.FINDFIRST;
WHILE NOT dbs."My Database" DO
  dbs.NEXT;

Message(srv."Server Name");
Message(dbs."Database Name");

The problem is, that this method spend several second.
Anyone know better way to do this?

Answers

  • ShedmanShedman Member Posts: 194
    Try using the search ...

    Or CONTEXTURL system variable.
  • garakgarak Member Posts: 3,263
    edited 2008-09-18
    These are examples to get the database name / Servername
    RecDB.SETRANGE("My Database",TRUE);
    RecDB.FINDFIRST;
    DBName := RecDB."Database Name";
    
    RecServer.SETRANGE("My Server",TRUE);
    RecServer.FINDFIRST;
    ServName := RecServer."Server Name";
    

    or
    MyContext := CONTEXTURL; 
    message('Servername = %1\'+
            'Database = %2',(copystr(MyContext,StrPos(MyContext,'servername') + 11,
                            StrPos(MyContext,'&data') - StrPos(MyContext,'servername')-11)),
                            (copystr(MyContext,StrPos(MyContext,'&data') + 10,
                             StrPos(MyContext,'&company') - StrPos(MyContext,'&data')-10)));
    
    Do you make it right, it works too!
  • zyyrafzyyraf Member Posts: 9
    Thank you very much :) - CONTEXTURL is excellent for my need.
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from Navision forum to Navision Tips & Tricks forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • SavatageSavatage Member Posts: 7,142
    With this post & other you can get something like this
    Sorry for my Old School Menu :oops:
  • garakgarak Member Posts: 3,263
    :shock: who are the girls ???? :lol:
    Do you make it right, it works too!
  • SavatageSavatage Member Posts: 7,142
  • garakgarak Member Posts: 3,263
    for my person, i can't work with "chicks" like these in my firm
    ... i'm ever distracted =P~ (jammi)

    :mrgreen:
    Do you make it right, it works too!
Sign In or Register to comment.