Fastest way to find current servername?

pdjpdj Member Posts: 643
edited 2004-08-25 in Navision Attain
I need to find the name of the SQL server, so I have made some simple code that finds it in the Server table:
Server.SETRANGE("My Server",TRUE);
Server.FIND('-');
However; this code is very slow. It takes at least 1 sec and sometime even more. Isn't it possible to find the information from the Database Information window directly? :-(

(Store it in a new table is not an option :-))
Regards
Peter

Comments

  • dijconadijcona Member Posts: 8
    Hi,

    Try

    name:=CONTEXTURL;
    i:=STRPOS(name,'database=');
    IF i > 0 THEN BEGIN
    name:=COPYSTR(name,i+9,999);
    i:=STRPOS(name,'&');
    dbName:=COPYSTR(name,1,i-1); END;

    This works fine for us and seems to be a lot quicker. We tried your other method as well and it as un-workable.

    Regards
    Meint
  • pdjpdj Member Posts: 643
    Great idea! Ended up doing it like this to find names of server and db:
    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-
    
    Thank you for leading me to the CONTEXTURL function 8)
    Regards
    Peter
Sign In or Register to comment.